Completed
Pull Request — master (#1687)
by
unknown
37:57 queued 16:53
created
includes/payments/actions.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_purchase', $payment_id );
61
+	do_action('give_pre_complete_purchase', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_purchase_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_purchase_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$customer = new Give_Customer( $customer_id );
89
+	$customer = new Give_Customer($customer_id);
90 90
 	$customer->increase_purchase_count();
91
-	$customer->increase_value( $amount );
91
+	$customer->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136 136
 	$status_change = sprintf(
137
-		esc_html__( 'Status changed from %1$s to %2$s.', 'give' ),
137
+		esc_html__('Status changed from %1$s to %2$s.', 'give'),
138 138
 		$old_status,
139 139
 		$new_status
140 140
 	);
141 141
 
142
-	give_insert_payment_note( $payment_id, $status_change );
142
+	give_insert_payment_note($payment_id, $status_change);
143 143
 }
144 144
 
145
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
145
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
146 146
 
147 147
 
148 148
 /**
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
  *
159 159
  * @return void
160 160
  */
161
-function give_update_old_payments_with_totals( $data ) {
162
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
161
+function give_update_old_payments_with_totals($data) {
162
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
166
+	if (get_option('give_payment_totals_upgraded')) {
167 167
 		return;
168 168
 	}
169 169
 
170
-	$payments = give_get_payments( array(
170
+	$payments = give_get_payments(array(
171 171
 		'offset' => 0,
172
-		'number' => - 1,
172
+		'number' => -1,
173 173
 		'mode'   => 'all',
174
-	) );
174
+	));
175 175
 
176
-	if ( $payments ) {
177
-		foreach ( $payments as $payment ) {
176
+	if ($payments) {
177
+		foreach ($payments as $payment) {
178 178
 
179
-			$payment = new Give_Payment( $payment->ID );
179
+			$payment = new Give_Payment($payment->ID);
180 180
 			$meta    = $payment->get_meta();
181 181
 
182 182
 			$payment->total = $meta['amount'];
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 		}
186 186
 	}
187 187
 
188
-	add_option( 'give_payment_totals_upgraded', 1 );
188
+	add_option('give_payment_totals_upgraded', 1);
189 189
 }
190 190
 
191
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
191
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
192 192
 
193 193
 /**
194 194
  * Mark Abandoned Donations
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 function give_mark_abandoned_donations() {
203 203
 	$args = array(
204 204
 		'status' => 'pending',
205
-		'number' => - 1,
205
+		'number' => -1,
206 206
 		'output' => 'give_payments',
207 207
 	);
208 208
 
209
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	add_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	$payments = give_get_payments( $args );
211
+	$payments = give_get_payments($args);
212 212
 
213
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
213
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
214 214
 
215
-	if ( $payments ) {
215
+	if ($payments) {
216 216
 		/**
217 217
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
218 218
 		 *
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 		 *
221 221
 		 * @param array $skip_payment_gateways Array of payment gateways
222 222
 		 */
223
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
223
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
224 224
 
225
-		foreach ( $payments as $payment ) {
226
-			$gateway = give_get_payment_gateway( $payment );
225
+		foreach ($payments as $payment) {
226
+			$gateway = give_get_payment_gateway($payment);
227 227
 
228 228
 			// Skip payment gateways.
229
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
229
+			if (in_array($gateway, $skip_payment_gateways)) {
230 230
 				continue;
231 231
 			}
232 232
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 }
238 238
 
239
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
239
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
240 240
 
241 241
 
242 242
 /**
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
  *
249 249
  * @return void
250 250
  */
251
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
251
+function give_refresh_thismonth_stat_transients($payment_ID) {
252 252
 	// Monthly stats.
253
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
253
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
254 254
 
255 255
 	// @todo: Refresh only range related stat cache
256 256
 	give_delete_donation_stats();
257 257
 }
258 258
 
259
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
259
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
Please login to merge, or discard this patch.
includes/formatting.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return mixed
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37
-	return give_get_option( 'thousands_separator', ',' );
37
+	return give_get_option('thousands_separator', ',');
38 38
 }
39 39
 
40 40
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return mixed
46 46
  */
47 47
 function give_get_price_decimal_separator() {
48
-	return give_get_option( 'decimal_separator', '.' );
48
+	return give_get_option('decimal_separator', '.');
49 49
 }
50 50
 
51 51
 /**
@@ -61,67 +61,67 @@  discard block
 block discarded – undo
61 61
  *
62 62
  * @return string $amount Newly sanitized amount
63 63
  */
64
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
64
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
65 65
 
66 66
 	// Bailout.
67
-	if ( empty( $number ) ) {
67
+	if (empty($number)) {
68 68
 		return $number;
69 69
 	}
70 70
 
71 71
 	// Remove slash from amount.
72 72
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
73 73
 	// To prevent notices and warning remove slash from amount/number.
74
-	$number = wp_unslash( $number );
74
+	$number = wp_unslash($number);
75 75
 
76 76
 	$thousand_separator = give_get_price_thousand_separator();
77 77
 
78 78
 	$locale   = localeconv();
79
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
79
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
80 80
 
81 81
 	// Remove locale from string
82
-	if ( ! is_float( $number ) ) {
83
-		$number = str_replace( $decimals, '.', $number );
82
+	if ( ! is_float($number)) {
83
+		$number = str_replace($decimals, '.', $number);
84 84
 	}
85 85
 
86 86
 	// Remove thousand amount formatting if amount has.
87 87
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
88 88
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
89
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
90
-		$number = str_replace( $thousand_separator, '', $number );
91
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
92
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
89
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
90
+		$number = str_replace($thousand_separator, '', $number);
91
+	} elseif (in_array($thousand_separator, $decimals)) {
92
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
93 93
 	}
94 94
 
95 95
 	// Remove non numeric entity before decimal separator.
96
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
96
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
97 97
 	$default_dp = give_get_price_decimals();
98 98
 
99 99
 	// Reset negative amount to zero.
100
-	if ( 0 > $number ) {
101
-		$number = number_format( 0, $default_dp, '.' );
100
+	if (0 > $number) {
101
+		$number = number_format(0, $default_dp, '.');
102 102
 	}
103 103
 
104 104
 	// If number does not have decimal then add number of decimals to it.
105 105
 	if (
106
-		false === strpos( $number, '.' )
107
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
106
+		false === strpos($number, '.')
107
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
108 108
 	) {
109
-		$number = number_format( $number, $default_dp, '.', '' );
109
+		$number = number_format($number, $default_dp, '.', '');
110 110
 	}
111 111
 
112 112
 	// Format number by custom number of decimals.
113
-	if ( false !== $dp ) {
114
-		$dp     = intval( is_bool( $dp ) ? $default_dp : $dp );
115
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
116
-		$number = number_format( floatval( $number ), $dp, '.', '' );
113
+	if (false !== $dp) {
114
+		$dp     = intval(is_bool($dp) ? $default_dp : $dp);
115
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
116
+		$number = number_format(floatval($number), $dp, '.', '');
117 117
 	}
118 118
 
119 119
 	// Trim zeros.
120
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
121
-		$number = rtrim( rtrim( $number, '0' ), '.' );
120
+	if ($trim_zeros && strstr($number, '.')) {
121
+		$number = rtrim(rtrim($number, '0'), '.');
122 122
 	}
123 123
 
124
-	return apply_filters( 'give_sanitize_amount', $number );
124
+	return apply_filters('give_sanitize_amount', $number);
125 125
 }
126 126
 
127 127
 /**
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
  *
135 135
  * @return string $amount   Newly formatted amount or Price Not Available
136 136
  */
137
-function give_format_amount( $amount, $decimals = true ) {
138
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
139
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
137
+function give_format_amount($amount, $decimals = true) {
138
+	$thousands_sep = give_get_option('thousands_separator', ',');
139
+	$decimal_sep   = give_get_option('decimal_separator', '.');
140 140
 
141
-	if ( empty( $amount ) ) {
141
+	if (empty($amount)) {
142 142
 		$amount = 0;
143 143
 	} else {
144 144
 		// Sanitize amount before formatting.
145
-		$amount = give_sanitize_amount( $amount );
145
+		$amount = give_sanitize_amount($amount);
146 146
 	}
147 147
 
148 148
 	$decimals = $decimals ? give_get_price_decimals() : 0;
149 149
 
150
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
150
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
151 151
 
152
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
152
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
153 153
 }
154 154
 
155 155
 
@@ -166,33 +166,33 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @return float|string  formatted amount number with large number names.
168 168
  */
169
-function give_human_format_large_amount( $amount ) {
169
+function give_human_format_large_amount($amount) {
170 170
 
171 171
 	// Get thousand separator.
172 172
 	$thousands_sep = give_get_price_thousand_separator();
173 173
 
174 174
 	// Sanitize amount.
175
-	$sanitize_amount = give_sanitize_amount( $amount );
175
+	$sanitize_amount = give_sanitize_amount($amount);
176 176
 
177 177
 	// Explode amount to calculate name of large numbers.
178
-	$amount_array = explode( $thousands_sep, $amount );
178
+	$amount_array = explode($thousands_sep, $amount);
179 179
 
180 180
 	// Calculate amount parts count.
181
-	$amount_count_parts = count( $amount_array );
181
+	$amount_count_parts = count($amount_array);
182 182
 
183 183
 	// Human format amount (default).
184 184
 	$human_format_amount = $amount;
185 185
 
186 186
 	// Calculate large number formatted amount.
187
-	if ( 4 < $amount_count_parts ) {
188
-		$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
189
-	} elseif ( 3 < $amount_count_parts ) {
190
-		$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
191
-	} elseif ( 2 < $amount_count_parts ) {
192
-		$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
187
+	if (4 < $amount_count_parts) {
188
+		$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
189
+	} elseif (3 < $amount_count_parts) {
190
+		$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
191
+	} elseif (2 < $amount_count_parts) {
192
+		$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
193 193
 	}
194 194
 
195
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
195
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
196 196
 }
197 197
 
198 198
 /**
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
  *
206 206
  * @return string $amount Newly formatted amount or Price Not Available
207 207
  */
208
-function give_format_decimal( $amount, $dp = false ) {
208
+function give_format_decimal($amount, $dp = false) {
209 209
 	$decimal_separator = give_get_price_decimal_separator();
210
-	$formatted_amount  = give_sanitize_amount( $amount, $dp );
210
+	$formatted_amount  = give_sanitize_amount($amount, $dp);
211 211
 
212
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
213
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
212
+	if (false !== strpos($formatted_amount, '.')) {
213
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
214 214
 	}
215 215
 
216
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
216
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
217 217
 }
218 218
 
219 219
 /**
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return mixed|string
228 228
  */
229
-function give_currency_filter( $price = '', $currency = '' ) {
229
+function give_currency_filter($price = '', $currency = '') {
230 230
 
231
-	if ( empty( $currency ) ) {
231
+	if (empty($currency)) {
232 232
 		$currency = give_get_currency();
233 233
 	}
234 234
 
235
-	$position = give_get_option( 'currency_position', 'before' );
235
+	$position = give_get_option('currency_position', 'before');
236 236
 
237 237
 	$negative = $price < 0;
238 238
 
239
-	if ( $negative ) {
239
+	if ($negative) {
240 240
 		// Remove proceeding "-".
241
-		$price = substr( $price, 1 );
241
+		$price = substr($price, 1);
242 242
 	}
243 243
 
244
-	$symbol = give_currency_symbol( $currency );
244
+	$symbol = give_currency_symbol($currency);
245 245
 
246
-	switch ( $currency ) :
246
+	switch ($currency) :
247 247
 		case 'GBP' :
248 248
 		case 'BRL' :
249 249
 		case 'EUR' :
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
 		case 'MAD' :
273 273
 		case 'KRW' :
274 274
 		case 'ZAR' :
275
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
275
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
276 276
 			break;
277 277
 		case 'NOK' :
278
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
278
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
279 279
 			break;
280 280
 		default :
281
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
281
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
282 282
 			break;
283 283
 	endswitch;
284 284
 
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	 *           and if currency is USD and currency position is after then
294 294
 	 *           filter name will be give_usd_currency_filter_after
295 295
 	 */
296
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
296
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
297 297
 
298
-	if ( $negative ) {
298
+	if ($negative) {
299 299
 		// Prepend the minus sign before the currency sign.
300
-		$formatted = '-' . $formatted;
300
+		$formatted = '-'.$formatted;
301 301
 	}
302 302
 
303 303
 	return $formatted;
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function give_currency_decimal_filter() {
315 315
 
316
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
316
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
317 317
 
318 318
 	// Set default number of decimals.
319 319
 	$decimals = give_get_price_decimals();
320 320
 
321
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
321
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
322 322
 
323 323
 	// Get number of decimals with backward compatibility ( version < 1.6 )
324
-	if ( 1 <= func_num_args() ) {
325
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
324
+	if (1 <= func_num_args()) {
325
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
326 326
 	}
327 327
 
328 328
 	$currency = give_get_currency();
329 329
 
330
-	switch ( $currency ) {
330
+	switch ($currency) {
331 331
 		case 'RIAL' :
332 332
 		case 'JPY' :
333 333
 		case 'TWD' :
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 			break;
338 338
 	}
339 339
 
340
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
340
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
341 341
 }
342 342
 
343
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
344
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
343
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
344
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
345 345
 
346 346
 
347 347
 /**
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
  *
354 354
  * @return string                  Date format string
355 355
  */
356
-function give_date_format( $date_context = '' ) {
356
+function give_date_format($date_context = '') {
357 357
 	/**
358 358
 	 * Filter the date context
359 359
 	 *
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 *    }
376 376
 	 */
377
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
377
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
378 378
 
379 379
 	// Set date format to default date format.
380
-	$date_format = get_option( 'date_format' );
380
+	$date_format = get_option('date_format');
381 381
 
382 382
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
383
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
384
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
385
-			? $date_format_contexts[ $date_context ]
383
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
384
+		$date_format = ! empty($date_format_contexts[$date_context])
385
+			? $date_format_contexts[$date_context]
386 386
 			: $date_format;
387 387
 	}
388 388
 
389
-	return apply_filters( 'give_date_format', $date_format );
389
+	return apply_filters('give_date_format', $date_format);
390 390
 }
391 391
 
392 392
 /**
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return string
402 402
  */
403
-function give_get_cache_key( $action, $query_args ) {
404
-	return Give_Cache::get_key( $action, $query_args );
403
+function give_get_cache_key($action, $query_args) {
404
+	return Give_Cache::get_key($action, $query_args);
405 405
 }
406 406
 
407 407
 /**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
  *
415 415
  * @return string|array
416 416
  */
417
-function give_clean( $var ) {
418
-	if ( is_array( $var ) ) {
419
-		return array_map( 'give_clean', $var );
417
+function give_clean($var) {
418
+	if (is_array($var)) {
419
+		return array_map('give_clean', $var);
420 420
 	} else {
421
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
421
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
422 422
 	}
423 423
 }
424 424
 
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
  *
432 432
  * @return int
433 433
  */
434
-function give_let_to_num( $size ) {
435
-	$l   = substr( $size, - 1 );
436
-	$ret = substr( $size, 0, - 1 );
437
-	switch ( strtoupper( $l ) ) {
434
+function give_let_to_num($size) {
435
+	$l   = substr($size, - 1);
436
+	$ret = substr($size, 0, - 1);
437
+	switch (strtoupper($l)) {
438 438
 		case 'P':
439 439
 			$ret *= 1024;
440 440
 		case 'T':
@@ -459,17 +459,17 @@  discard block
 block discarded – undo
459 459
  * @param int   $action
460 460
  * @param array $wp_die_args
461 461
  */
462
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
462
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
463 463
 
464 464
 	$default_wp_die_args = array(
465
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
466
-		'title'   => esc_html__( 'Error', 'give' ),
467
-		'args'    => array( 'response' => 403 ),
465
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
466
+		'title'   => esc_html__('Error', 'give'),
467
+		'args'    => array('response' => 403),
468 468
 	);
469 469
 
470
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
470
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
471 471
 
472
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
472
+	if ( ! wp_verify_nonce($nonce, $action)) {
473 473
 		wp_die(
474 474
 			$wp_die_args['message'],
475 475
 			$wp_die_args['title'],
@@ -491,23 +491,23 @@  discard block
 block discarded – undo
491 491
  *
492 492
  * @return mixed
493 493
  */
494
-function give_check_variable( $variable, $conditional = '', $default = false ) {
494
+function give_check_variable($variable, $conditional = '', $default = false) {
495 495
 
496
-	switch ( $conditional ) {
496
+	switch ($conditional) {
497 497
 		case 'isset_empty':
498
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
498
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
499 499
 			break;
500 500
 
501 501
 		case 'empty':
502
-			$variable = ! empty( $variable ) ? $variable : $default;
502
+			$variable = ! empty($variable) ? $variable : $default;
503 503
 			break;
504 504
 
505 505
 		case 'null':
506
-			$variable = ! is_null( $variable ) ? $variable : $default;
506
+			$variable = ! is_null($variable) ? $variable : $default;
507 507
 			break;
508 508
 
509 509
 		default:
510
-			$variable = isset( $variable ) ? $variable : $default;
510
+			$variable = isset($variable) ? $variable : $default;
511 511
 
512 512
 	}
513 513
 
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 }
50 50
 
51
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
51
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
52 52
 
53 53
 /**
54 54
  * Run the Give Install process.
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 	give_setup_post_types();
65 65
 
66 66
 	// Clear the permalinks.
67
-	flush_rewrite_rules( false );
67
+	flush_rewrite_rules(false);
68 68
 
69 69
 	// Add Upgraded From Option.
70
-	$current_version = get_option( 'give_version' );
71
-	if ( $current_version ) {
72
-		update_option( 'give_version_upgraded_from', $current_version );
70
+	$current_version = get_option('give_version');
71
+	if ($current_version) {
72
+		update_option('give_version_upgraded_from', $current_version);
73 73
 	}
74 74
 
75 75
 	// Setup some default options.
76 76
 	$options = array();
77 77
 
78 78
 	// Checks if the Success Page option exists AND that the page exists.
79
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
79
+	if ( ! get_post(give_get_option('success_page'))) {
80 80
 
81 81
 		// Donation Confirmation (Success) Page
82 82
 		$success = wp_insert_post(
83 83
 			array(
84
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
84
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
85 85
 				'post_content'   => '[give_receipt]',
86 86
 				'post_status'    => 'publish',
87 87
 				'post_author'    => 1,
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Checks if the Failure Page option exists AND that the page exists.
98
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
98
+	if ( ! get_post(give_get_option('failure_page'))) {
99 99
 
100 100
 		// Failed Donation Page
101 101
 		$failed = wp_insert_post(
102 102
 			array(
103
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
104
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
103
+				'post_title'     => esc_html__('Donation Failed', 'give'),
104
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
105 105
 				'post_status'    => 'publish',
106 106
 				'post_author'    => 1,
107 107
 				'post_type'      => 'page',
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 
115 115
 	// Checks if the History Page option exists AND that the page exists.
116
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
116
+	if ( ! get_post(give_get_option('history_page'))) {
117 117
 		// Donation History Page
118 118
 		$history = wp_insert_post(
119 119
 			array(
120
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
120
+				'post_title'     => esc_html__('Donation History', 'give'),
121 121
 				'post_content'   => '[donation_history]',
122 122
 				'post_status'    => 'publish',
123 123
 				'post_author'    => 1,
@@ -130,23 +130,23 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
133
-	if ( empty( $current_version ) ) {
134
-		$options = array_merge( $options, give_get_default_settings() );
133
+	if (empty($current_version)) {
134
+		$options = array_merge($options, give_get_default_settings());
135 135
 	}
136 136
 
137 137
 	// Populate the default values.
138
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
138
+	update_option('give_settings', array_merge($give_options, $options));
139 139
 
140 140
 	/**
141 141
 	 * Run plugin upgrades.
142 142
 	 *
143 143
 	 * @since 1.8
144 144
 	 */
145
-	do_action( 'give_upgrades' );
145
+	do_action('give_upgrades');
146 146
 
147 147
 
148
-	if( GIVE_VERSION !== get_option( 'give_version' ) ) {
149
-		update_option( 'give_version', GIVE_VERSION );
148
+	if (GIVE_VERSION !== get_option('give_version')) {
149
+		update_option('give_version', GIVE_VERSION);
150 150
 	}
151 151
 
152 152
 	// Create Give roles.
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	$roles->add_caps();
156 156
 
157 157
 	$api = new Give_API();
158
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
158
+	update_option('give_default_api_version', 'v'.$api->get_version());
159 159
 
160 160
 	// Create the customers databases.
161 161
 	@Give()->customers->create_table();
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	Give()->session->use_php_sessions();
166 166
 
167 167
 	// Add a temporary option to note that Give pages have been created.
168
-	Give_Cache::set( '_give_installed', $options, 30, true );
168
+	Give_Cache::set('_give_installed', $options, 30, true);
169 169
 
170
-	if ( ! $current_version ) {
170
+	if ( ! $current_version) {
171 171
 
172
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
172
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
173 173
 
174 174
 		// When new upgrade routines are added, mark them as complete on fresh install.
175 175
 		$upgrade_routines = array(
@@ -180,22 +180,22 @@  discard block
 block discarded – undo
180 180
 			'v18_upgrades_form_metadata'
181 181
 		);
182 182
 
183
-		foreach ( $upgrade_routines as $upgrade ) {
184
-			give_set_upgrade_complete( $upgrade );
183
+		foreach ($upgrade_routines as $upgrade) {
184
+			give_set_upgrade_complete($upgrade);
185 185
 		}
186 186
 	}
187 187
 
188 188
 	// Bail if activating from network, or bulk.
189
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
189
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
190 190
 		return;
191 191
 	}
192 192
 
193 193
 	// Add the transient to redirect.
194
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
194
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
195 195
 
196 196
 }
197 197
 
198
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
198
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
199 199
 
200 200
 /**
201 201
  * Network Activated New Site Setup.
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
  * @param  int    $site_id The Site ID.
212 212
  * @param  array  $meta    Blog Meta.
213 213
  */
214
-function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
214
+function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
215 215
 
216
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
216
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
217 217
 
218
-		switch_to_blog( $blog_id );
218
+		switch_to_blog($blog_id);
219 219
 		give_install();
220 220
 		restore_current_blog();
221 221
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 }
225 225
 
226
-add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
226
+add_action('wpmu_new_blog', 'on_create_blog', 10, 6);
227 227
 
228 228
 
229 229
 /**
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
  *
237 237
  * @return array          The tables to drop.
238 238
  */
239
-function give_wpmu_drop_tables( $tables, $blog_id ) {
239
+function give_wpmu_drop_tables($tables, $blog_id) {
240 240
 
241
-	switch_to_blog( $blog_id );
241
+	switch_to_blog($blog_id);
242 242
 	$customers_db     = new Give_DB_Customers();
243 243
 	$customer_meta_db = new Give_DB_Customer_Meta();
244 244
 
245
-	if ( $customers_db->installed() ) {
245
+	if ($customers_db->installed()) {
246 246
 		$tables[] = $customers_db->table_name;
247 247
 		$tables[] = $customer_meta_db->table_name;
248 248
 	}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 }
254 254
 
255
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
255
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
256 256
 
257 257
 /**
258 258
  * Post-installation
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function give_after_install() {
266 266
 
267
-	if ( ! is_admin() ) {
267
+	if ( ! is_admin()) {
268 268
 		return;
269 269
 	}
270 270
 
271
-	$give_options     = Give_Cache::get( '_give_installed', true );
272
-	$give_table_check = get_option( '_give_table_check', false );
271
+	$give_options     = Give_Cache::get('_give_installed', true);
272
+	$give_table_check = get_option('_give_table_check', false);
273 273
 
274
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
274
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
275 275
 
276
-		if ( ! @Give()->customer_meta->installed() ) {
276
+		if ( ! @Give()->customer_meta->installed()) {
277 277
 
278 278
 			// Create the customer meta database
279 279
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		}
283 283
 
284
-		if ( ! @Give()->customers->installed() ) {
284
+		if ( ! @Give()->customers->installed()) {
285 285
 			// Create the customers database
286 286
 			// (this ensures it creates it on multisite instances where it is network activated).
287 287
 			@Give()->customers->create_table();
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
 			 *
294 294
 			 * @param array $give_options Give plugin options.
295 295
 			 */
296
-			do_action( 'give_after_install', $give_options );
296
+			do_action('give_after_install', $give_options);
297 297
 		}
298 298
 
299
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
299
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
300 300
 
301 301
 	}
302 302
 
303 303
 	// Delete the transient
304
-	if ( false !== $give_options ) {
305
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
304
+	if (false !== $give_options) {
305
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
306 306
 	}
307 307
 
308 308
 
309 309
 }
310 310
 
311
-add_action( 'admin_init', 'give_after_install' );
311
+add_action('admin_init', 'give_after_install');
312 312
 
313 313
 
314 314
 /**
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 
324 324
 	global $wp_roles;
325 325
 
326
-	if ( ! is_object( $wp_roles ) ) {
326
+	if ( ! is_object($wp_roles)) {
327 327
 		return;
328 328
 	}
329 329
 
330
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
330
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
331 331
 
332 332
 		// Create Give plugin roles
333 333
 		$roles = new Give_Roles();
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
 }
340 340
 
341
-add_action( 'admin_init', 'give_install_roles_on_network' );
341
+add_action('admin_init', 'give_install_roles_on_network');
342 342
 
343 343
 /**
344 344
  * Default core setting values.
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		'paypal_verification'                         => 'enabled',
379 379
 
380 380
 		// Default is manual gateway.
381
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
381
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
382 382
 		'default_gateway'                             => 'manual',
383 383
 
384 384
 		// Offline gateway setup.
Please login to merge, or discard this patch.
includes/admin/class-give-settings.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param $url
74 74
 	 *
75
-	 * @return mixed
75
+	 * @return string
76 76
 	 */
77 77
 	public function give_update_cmb_meta_box_url( $url ) {
78 78
 		// Path to Give's CMB
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  * @since      1.3.5
936 936
  *
937 937
  * @param $array
938
- * @param $position |int|string Expects an array key or 'id' of the settings field to appear after
938
+ * @param string $position |int|string Expects an array key or 'id' of the settings field to appear after
939 939
  * @param $insert   |array a valid array of options to insert
940 940
  *
941 941
  * @return array
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  * @since 1.0
975 975
  *
976 976
  * @param array $field_arr
977
- * @param array $saved_values
977
+ * @param string|boolean $saved_values
978 978
  *
979 979
  * @return void
980 980
  */
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
  * @since  1.0
1010 1010
  *
1011 1011
  * @param  array $field_arr
1012
- * @param  array $saved_value
1012
+ * @param  string|boolean $saved_value
1013 1013
  *
1014 1014
  * @return void
1015 1015
  */
Please login to merge, or discard this patch.
Spacing   +362 added lines, -362 removed lines patch added patch discarded remove patch
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 	public function __construct() {
44 44
 
45 45
 		// Custom CMB2 Settings Fields
46
-		add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 );
47
-		add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 );
48
-		add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 );
49
-		add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 );
50
-		add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 );
51
-		add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 );
52
-		add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 );
53
-		add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 );
46
+		add_action('cmb2_render_give_title', 'give_title_callback', 10, 5);
47
+		add_action('cmb2_render_give_description', 'give_description_callback', 10, 5);
48
+		add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5);
49
+		add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5);
50
+		add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5);
51
+		add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5);
52
+		add_action('cmb2_render_api', 'give_api_callback', 10, 5);
53
+		add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5);
54 54
 	}
55 55
 
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @since  1.0
61 61
 	 */
62 62
 	public function init() {
63
-		register_setting( $this->key, $this->key );
63
+		register_setting($this->key, $this->key);
64 64
 
65 65
 	}
66 66
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return mixed
76 76
 	 */
77
-	public function give_update_cmb_meta_box_url( $url ) {
77
+	public function give_update_cmb_meta_box_url($url) {
78 78
 		// Path to Give's CMB
79
-		return GIVE_PLUGIN_URL . '/includes/libraries/cmb2';
79
+		return GIVE_PLUGIN_URL.'/includes/libraries/cmb2';
80 80
 	}
81 81
 
82 82
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function give_get_settings_tabs() {
90 90
 
91
-		$settings = $this->give_settings( null );
91
+		$settings = $this->give_settings(null);
92 92
 
93 93
 		$tabs             = array();
94
-		$tabs['general']  = __( 'General', 'give' );
95
-		$tabs['gateways'] = __( 'Payment Gateways', 'give' );
96
-		$tabs['display']  = __( 'Display Options', 'give' );
97
-		$tabs['emails']   = __( 'Emails', 'give' );
94
+		$tabs['general']  = __('General', 'give');
95
+		$tabs['gateways'] = __('Payment Gateways', 'give');
96
+		$tabs['display']  = __('Display Options', 'give');
97
+		$tabs['emails']   = __('Emails', 'give');
98 98
 
99
-		if ( ! empty( $settings['addons']['fields'] ) ) {
100
-			$tabs['addons'] = __( 'Add-ons', 'give' );
99
+		if ( ! empty($settings['addons']['fields'])) {
100
+			$tabs['addons'] = __('Add-ons', 'give');
101 101
 		}
102 102
 
103
-		if ( ! empty( $settings['licenses']['fields'] ) ) {
104
-			$tabs['licenses'] = __( 'Licenses', 'give' );
103
+		if ( ! empty($settings['licenses']['fields'])) {
104
+			$tabs['licenses'] = __('Licenses', 'give');
105 105
 		}
106 106
 
107
-		$tabs['advanced']    = __( 'Advanced', 'give' );
108
-		$tabs['api']         = __( 'API', 'give' );
109
-		$tabs['system_info'] = __( 'System Info', 'give' );
107
+		$tabs['advanced']    = __('Advanced', 'give');
108
+		$tabs['api']         = __('API', 'give');
109
+		$tabs['system_info'] = __('System Info', 'give');
110 110
 
111
-		return apply_filters( 'give_settings_tabs', $tabs );
111
+		return apply_filters('give_settings_tabs', $tabs);
112 112
 	}
113 113
 
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function admin_page_display() {
121 121
 
122
-		$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general';
122
+		$active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general';
123 123
 
124 124
 		?>
125 125
 
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
 			<h2 class="nav-tab-wrapper">
131 131
 				<?php
132
-				foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) {
132
+				foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) {
133 133
 
134
-					$tab_url = esc_url( add_query_arg( array(
134
+					$tab_url = esc_url(add_query_arg(array(
135 135
 						'settings-updated' => false,
136 136
 						'tab'              => $tab_id,
137
-					) ) );
137
+					)));
138 138
 
139 139
 					$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
140 140
 
141
-					echo '<a href="' . esc_url( $tab_url ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>';
141
+					echo '<a href="'.esc_url($tab_url).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>';
142 142
 
143 143
 				}
144 144
 				?>
145 145
 			</h2>
146 146
 
147
-			<?php cmb2_metabox_form( $this->give_settings( $active_tab ), $this->key ); ?>
147
+			<?php cmb2_metabox_form($this->give_settings($active_tab), $this->key); ?>
148 148
 
149 149
 		</div><!-- .wrap -->
150 150
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return string
168 168
 	 */
169
-	function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) {
169
+	function give_modify_cmb2_form_output($form_format, $object_id, $cmb) {
170 170
 
171 171
 		// only modify the give settings form
172
-		if ( 'give_settings' == $object_id ) {
172
+		if ('give_settings' == $object_id) {
173 173
 
174
-			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . esc_attr__( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>';
174
+			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.esc_attr__('Save Settings', 'give').'" class="button-primary"></div></form>';
175 175
 
176 176
 		}
177 177
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return array
190 190
 	 */
191
-	public function give_settings( $active_tab ) {
191
+	public function give_settings($active_tab) {
192 192
 
193 193
 		$give_settings = array(
194 194
 			/**
@@ -196,99 +196,99 @@  discard block
 block discarded – undo
196 196
 			 */
197 197
 			'general'     => array(
198 198
 				'id'         => 'general_settings',
199
-				'give_title' => __( 'General Settings', 'give' ),
200
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
201
-				'fields'     => apply_filters( 'give_settings_general', array(
199
+				'give_title' => __('General Settings', 'give'),
200
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
201
+				'fields'     => apply_filters('give_settings_general', array(
202 202
 						array(
203
-							'name' => __( 'General Settings', 'give' ),
203
+							'name' => __('General Settings', 'give'),
204 204
 							'desc' => '',
205 205
 							'type' => 'give_title',
206 206
 							'id'   => 'give_title_general_settings_1',
207 207
 						),
208 208
 						array(
209
-							'name'    => __( 'Success Page', 'give' ),
209
+							'name'    => __('Success Page', 'give'),
210 210
 							/* translators: %s: [give_receipt] */
211
-							'desc'    => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
211
+							'desc'    => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'),
212 212
 							'id'      => 'success_page',
213 213
 							'type'    => 'select',
214
-							'options' => give_cmb2_get_post_options( array(
214
+							'options' => give_cmb2_get_post_options(array(
215 215
 								'post_type'   => 'page',
216
-								'numberposts' => - 1,
217
-							) ),
216
+								'numberposts' => -1,
217
+							)),
218 218
 						),
219 219
 						array(
220
-							'name'    => __( 'Failed Donation Page', 'give' ),
221
-							'desc'    => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ),
220
+							'name'    => __('Failed Donation Page', 'give'),
221
+							'desc'    => __('The page donors are sent to if their donation is cancelled or fails.', 'give'),
222 222
 							'id'      => 'failure_page',
223 223
 							'type'    => 'select',
224
-							'options' => give_cmb2_get_post_options( array(
224
+							'options' => give_cmb2_get_post_options(array(
225 225
 								'post_type'   => 'page',
226
-								'numberposts' => - 1,
227
-							) ),
226
+								'numberposts' => -1,
227
+							)),
228 228
 						),
229 229
 						array(
230
-							'name'    => __( 'Donation History Page', 'give' ),
230
+							'name'    => __('Donation History Page', 'give'),
231 231
 							/* translators: %s: [donation_history] */
232
-							'desc'    => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
232
+							'desc'    => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'),
233 233
 							'id'      => 'history_page',
234 234
 							'type'    => 'select',
235
-							'options' => give_cmb2_get_post_options( array(
235
+							'options' => give_cmb2_get_post_options(array(
236 236
 								'post_type'   => 'page',
237
-								'numberposts' => - 1,
238
-							) ),
237
+								'numberposts' => -1,
238
+							)),
239 239
 						),
240 240
 						array(
241
-							'name'    => __( 'Base Country', 'give' ),
242
-							'desc'    => __( 'The country your site operates from.', 'give' ),
241
+							'name'    => __('Base Country', 'give'),
242
+							'desc'    => __('The country your site operates from.', 'give'),
243 243
 							'id'      => 'base_country',
244 244
 							'type'    => 'select',
245 245
 							'options' => give_get_country_list(),
246 246
 						),
247 247
 						array(
248
-							'name' => __( 'Currency Settings', 'give' ),
248
+							'name' => __('Currency Settings', 'give'),
249 249
 							'desc' => '',
250 250
 							'type' => 'give_title',
251 251
 							'id'   => 'give_title_general_settings_2',
252 252
 						),
253 253
 						array(
254
-							'name'    => __( 'Currency', 'give' ),
255
-							'desc'    => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ),
254
+							'name'    => __('Currency', 'give'),
255
+							'desc'    => __('The donation currency. Note that some payment gateways have currency restrictions.', 'give'),
256 256
 							'id'      => 'currency',
257 257
 							'type'    => 'select',
258 258
 							'options' => give_get_currencies(),
259 259
 							'default' => 'USD',
260 260
 						),
261 261
 						array(
262
-							'name'    => __( 'Currency Position', 'give' ),
263
-							'desc'    => __( 'The position of the currency symbol.', 'give' ),
262
+							'name'    => __('Currency Position', 'give'),
263
+							'desc'    => __('The position of the currency symbol.', 'give'),
264 264
 							'id'      => 'currency_position',
265 265
 							'type'    => 'select',
266 266
 							'options' => array(
267 267
 								/* translators: %s: currency symbol */
268
-								'before' => sprintf( __( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ),
268
+								'before' => sprintf(__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())),
269 269
 								/* translators: %s: currency symbol */
270
-								'after'  => sprintf( __( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ),
270
+								'after'  => sprintf(__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())),
271 271
 							),
272 272
 							'default' => 'before',
273 273
 						),
274 274
 						array(
275
-							'name'            => __( 'Thousands Separator', 'give' ),
276
-							'desc'            => __( 'The symbol (usually , or .) to separate thousands.', 'give' ),
275
+							'name'            => __('Thousands Separator', 'give'),
276
+							'desc'            => __('The symbol (usually , or .) to separate thousands.', 'give'),
277 277
 							'id'              => 'thousands_separator',
278 278
 							'type'            => 'text_small',
279 279
 							'sanitization_cb' => 'give_sanitize_thousand_separator',
280 280
 							'default'         => ',',
281 281
 						),
282 282
 						array(
283
-							'name'    => __( 'Decimal Separator', 'give' ),
284
-							'desc'    => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
283
+							'name'    => __('Decimal Separator', 'give'),
284
+							'desc'    => __('The symbol (usually , or .) to separate decimal points.', 'give'),
285 285
 							'id'      => 'decimal_separator',
286 286
 							'type'    => 'text_small',
287 287
 							'default' => '.',
288 288
 						),
289 289
 						array(
290
-							'name'            => __( 'Number of Decimals', 'give' ),
291
-							'desc'            => __( 'The number of decimal points displayed in amounts.', 'give' ),
290
+							'name'            => __('Number of Decimals', 'give'),
291
+							'desc'            => __('The number of decimal points displayed in amounts.', 'give'),
292 292
 							'id'              => 'number_decimals',
293 293
 							'type'            => 'text_small',
294 294
 							'default'         => 2,
@@ -302,83 +302,83 @@  discard block
 block discarded – undo
302 302
 			 */
303 303
 			'gateways'    => array(
304 304
 				'id'         => 'payment_gateways',
305
-				'give_title' => __( 'Payment Gateways', 'give' ),
306
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
307
-				'fields'     => apply_filters( 'give_settings_gateways', array(
305
+				'give_title' => __('Payment Gateways', 'give'),
306
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
307
+				'fields'     => apply_filters('give_settings_gateways', array(
308 308
 						array(
309
-							'name' => __( 'Gateways Settings', 'give' ),
309
+							'name' => __('Gateways Settings', 'give'),
310 310
 							'desc' => '',
311 311
 							'id'   => 'give_title_gateway_settings_1',
312 312
 							'type' => 'give_title',
313 313
 						),
314 314
 						array(
315
-							'name' => __( 'Test Mode', 'give' ),
316
-							'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
315
+							'name' => __('Test Mode', 'give'),
316
+							'desc' => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'),
317 317
 							'id'   => 'test_mode',
318 318
 							'type' => 'checkbox',
319 319
 						),
320 320
 						array(
321
-							'name' => __( 'Enabled Gateways', 'give' ),
322
-							'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
321
+							'name' => __('Enabled Gateways', 'give'),
322
+							'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'),
323 323
 							'id'   => 'gateways',
324 324
 							'type' => 'enabled_gateways',
325 325
 						),
326 326
 						array(
327
-							'name' => __( 'Default Gateway', 'give' ),
328
-							'desc' => __( 'The gateway that will be selected by default.', 'give' ),
327
+							'name' => __('Default Gateway', 'give'),
328
+							'desc' => __('The gateway that will be selected by default.', 'give'),
329 329
 							'id'   => 'default_gateway',
330 330
 							'type' => 'default_gateway',
331 331
 						),
332 332
 						array(
333
-							'name' => __( 'PayPal Standard', 'give' ),
333
+							'name' => __('PayPal Standard', 'give'),
334 334
 							'desc' => '',
335 335
 							'type' => 'give_title',
336 336
 							'id'   => 'give_title_gateway_settings_2',
337 337
 						),
338 338
 						array(
339
-							'name' => __( 'PayPal Email', 'give' ),
340
-							'desc' => __( 'Enter your PayPal account\'s email.', 'give' ),
339
+							'name' => __('PayPal Email', 'give'),
340
+							'desc' => __('Enter your PayPal account\'s email.', 'give'),
341 341
 							'id'   => 'paypal_email',
342 342
 							'type' => 'text_email',
343 343
 						),
344 344
 						array(
345
-							'name' => __( 'PayPal Page Style', 'give' ),
346
-							'desc' => __( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ),
345
+							'name' => __('PayPal Page Style', 'give'),
346
+							'desc' => __('Enter the name of the page style to use, or leave blank to use the default.', 'give'),
347 347
 							'id'   => 'paypal_page_style',
348 348
 							'type' => 'text',
349 349
 						),
350 350
 						array(
351
-							'name'    => __( 'PayPal Transaction Type', 'give' ),
352
-							'desc'    => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
351
+							'name'    => __('PayPal Transaction Type', 'give'),
352
+							'desc'    => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'),
353 353
 							'id'      => 'paypal_button_type',
354 354
 							'type'    => 'radio_inline',
355 355
 							'options' => array(
356
-								'donation' => __( 'Donation', 'give' ),
357
-								'standard' => __( 'Standard Transaction', 'give' ),
356
+								'donation' => __('Donation', 'give'),
357
+								'standard' => __('Standard Transaction', 'give'),
358 358
 							),
359 359
 							'default' => 'donation',
360 360
 						),
361 361
 						array(
362
-							'name' => __( 'Disable PayPal IPN Verification', 'give' ),
363
-							'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
362
+							'name' => __('Disable PayPal IPN Verification', 'give'),
363
+							'desc' => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'),
364 364
 							'id'   => 'disable_paypal_verification',
365 365
 							'type' => 'checkbox',
366 366
 						),
367 367
 						array(
368
-							'name' => __( 'Offline Donations', 'give' ),
368
+							'name' => __('Offline Donations', 'give'),
369 369
 							'desc' => '',
370 370
 							'type' => 'give_title',
371 371
 							'id'   => 'give_title_gateway_settings_3',
372 372
 						),
373 373
 						array(
374
-							'name' => __( 'Collect Billing Details', 'give' ),
375
-							'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
374
+							'name' => __('Collect Billing Details', 'give'),
375
+							'desc' => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'),
376 376
 							'id'   => 'give_offline_donation_enable_billing_fields',
377 377
 							'type' => 'checkbox',
378 378
 						),
379 379
 						array(
380
-							'name'    => __( 'Offline Donation Instructions', 'give' ),
381
-							'desc'    => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
380
+							'name'    => __('Offline Donation Instructions', 'give'),
381
+							'desc'    => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'),
382 382
 							'id'      => 'global_offline_donation_content',
383 383
 							'default' => give_get_default_offline_donation_content(),
384 384
 							'type'    => 'wysiwyg',
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
 							),
388 388
 						),
389 389
 						array(
390
-							'name'    => __( 'Offline Donation Email Instructions Subject', 'give' ),
391
-							'desc'    => __( 'Enter the subject line for the donation receipt email.', 'give' ),
390
+							'name'    => __('Offline Donation Email Instructions Subject', 'give'),
391
+							'desc'    => __('Enter the subject line for the donation receipt email.', 'give'),
392 392
 							'id'      => 'offline_donation_subject',
393
-							'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
393
+							'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
394 394
 							'type'    => 'text',
395 395
 						),
396 396
 						array(
397
-							'name'    => __( 'Offline Donation Email Instructions', 'give' ),
398
-							'desc'    => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
397
+							'name'    => __('Offline Donation Email Instructions', 'give'),
398
+							'desc'    => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
399 399
 							'id'      => 'global_offline_donation_email',
400 400
 							'default' => give_get_default_offline_donation_email_content(),
401 401
 							'type'    => 'wysiwyg',
@@ -409,104 +409,104 @@  discard block
 block discarded – undo
409 409
 			/** Display Settings */
410 410
 			'display'     => array(
411 411
 				'id'         => 'display_settings',
412
-				'give_title' => __( 'Display Settings', 'give' ),
413
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
414
-				'fields'     => apply_filters( 'give_settings_display', array(
412
+				'give_title' => __('Display Settings', 'give'),
413
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
414
+				'fields'     => apply_filters('give_settings_display', array(
415 415
 						array(
416
-							'name' => __( 'Display Settings', 'give' ),
416
+							'name' => __('Display Settings', 'give'),
417 417
 							'desc' => '',
418 418
 							'id'   => 'give_title_display_settings_1',
419 419
 							'type' => 'give_title',
420 420
 						),
421 421
 						array(
422
-							'name' => __( 'Disable CSS', 'give' ),
423
-							'desc' => __( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ),
422
+							'name' => __('Disable CSS', 'give'),
423
+							'desc' => __('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'),
424 424
 							'id'   => 'disable_css',
425 425
 							'type' => 'checkbox',
426 426
 						),
427 427
 						array(
428
-							'name' => __( 'Enable Floating Labels', 'give' ),
428
+							'name' => __('Enable Floating Labels', 'give'),
429 429
 							/* translators: %s: http://docs.givewp.com/form-floating-labels */
430
-							'desc' => sprintf( wp_kses( __( 'Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array(
430
+							'desc' => sprintf(wp_kses(__('Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array(
431 431
 								'a' => array(
432 432
 									'href'   => array(),
433 433
 									'target' => array(),
434 434
 								),
435
-							) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
435
+							)), esc_url('http://docs.givewp.com/form-floating-labels')),
436 436
 							'id'   => 'floatlabels',
437 437
 							'type' => 'checkbox',
438 438
 						),
439 439
 						array(
440
-							'name' => __( 'Disable Welcome Screen', 'give' ),
440
+							'name' => __('Disable Welcome Screen', 'give'),
441 441
 							/* translators: %s: about page URL */
442
-							'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give' ), array(
442
+							'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give'), array(
443 443
 								'a' => array(
444 444
 									'href'   => array(),
445 445
 									'target' => array(),
446 446
 								),
447
-							) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
447
+							)), esc_url(admin_url('index.php?page=give-about'))),
448 448
 							'id'   => 'disable_welcome',
449 449
 							'type' => 'checkbox',
450 450
 						),
451 451
 						array(
452
-							'name' => __( 'Post Types', 'give' ),
452
+							'name' => __('Post Types', 'give'),
453 453
 							'desc' => '',
454 454
 							'id'   => 'give_title_display_settings_2',
455 455
 							'type' => 'give_title',
456 456
 						),
457 457
 						array(
458
-							'name' => __( 'Disable Form Single Views', 'give' ),
459
-							'desc' => __( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ),
458
+							'name' => __('Disable Form Single Views', 'give'),
459
+							'desc' => __('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'),
460 460
 							'id'   => 'disable_forms_singular',
461 461
 							'type' => 'checkbox',
462 462
 						),
463 463
 						array(
464
-							'name' => __( 'Disable Form Archives', 'give' ),
465
-							'desc' => __( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ),
464
+							'name' => __('Disable Form Archives', 'give'),
465
+							'desc' => __('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'),
466 466
 							'id'   => 'disable_forms_archives',
467 467
 							'type' => 'checkbox',
468 468
 						),
469 469
 						array(
470
-							'name' => __( 'Disable Form Excerpts', 'give' ),
471
-							'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
470
+							'name' => __('Disable Form Excerpts', 'give'),
471
+							'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'),
472 472
 							'id'   => 'disable_forms_excerpt',
473 473
 							'type' => 'checkbox',
474 474
 						),
475 475
 						array(
476
-							'name'    => __( 'Featured Image Size', 'give' ),
477
-							'desc'    => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ),
476
+							'name'    => __('Featured Image Size', 'give'),
477
+							'desc'    => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'),
478 478
 							'id'      => 'featured_image_size',
479 479
 							'type'    => 'select',
480 480
 							'default' => 'large',
481 481
 							'options' => give_get_featured_image_sizes(),
482 482
 						),
483 483
 						array(
484
-							'name' => __( 'Disable Form Featured Image', 'give' ),
485
-							'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ),
484
+							'name' => __('Disable Form Featured Image', 'give'),
485
+							'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'),
486 486
 							'id'   => 'disable_form_featured_img',
487 487
 							'type' => 'checkbox',
488 488
 						),
489 489
 						array(
490
-							'name' => __( 'Disable Single Form Sidebar', 'give' ),
491
-							'desc' => __( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ),
490
+							'name' => __('Disable Single Form Sidebar', 'give'),
491
+							'desc' => __('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'),
492 492
 							'id'   => 'disable_form_sidebar',
493 493
 							'type' => 'checkbox',
494 494
 						),
495 495
 						array(
496
-							'name' => __( 'Taxonomies', 'give' ),
496
+							'name' => __('Taxonomies', 'give'),
497 497
 							'desc' => '',
498 498
 							'id'   => 'give_title_display_settings_3',
499 499
 							'type' => 'give_title',
500 500
 						),
501 501
 						array(
502
-							'name' => __( 'Enable Form Categories', 'give' ),
503
-							'desc' => __( 'Enables the "Category" taxonomy for all Give forms.', 'give' ),
502
+							'name' => __('Enable Form Categories', 'give'),
503
+							'desc' => __('Enables the "Category" taxonomy for all Give forms.', 'give'),
504 504
 							'id'   => 'categories',
505 505
 							'type' => 'checkbox',
506 506
 						),
507 507
 						array(
508
-							'name' => __( 'Enable Form Tags', 'give' ),
509
-							'desc' => __( 'Enables the "Tag" taxonomy for all Give forms.', 'give' ),
508
+							'name' => __('Enable Form Tags', 'give'),
509
+							'desc' => __('Enables the "Tag" taxonomy for all Give forms.', 'give'),
510 510
 							'id'   => 'tags',
511 511
 							'type' => 'checkbox',
512 512
 						),
@@ -519,101 +519,101 @@  discard block
 block discarded – undo
519 519
 			 */
520 520
 			'emails'      => array(
521 521
 				'id'         => 'email_settings',
522
-				'give_title' => __( 'Email Settings', 'give' ),
523
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
524
-				'fields'     => apply_filters( 'give_settings_emails', array(
522
+				'give_title' => __('Email Settings', 'give'),
523
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
524
+				'fields'     => apply_filters('give_settings_emails', array(
525 525
 						array(
526
-							'name' => __( 'Email Settings', 'give' ),
526
+							'name' => __('Email Settings', 'give'),
527 527
 							'desc' => '',
528 528
 							'id'   => 'give_title_email_settings_1',
529 529
 							'type' => 'give_title',
530 530
 						),
531 531
 						array(
532 532
 							'id'      => 'email_template',
533
-							'name'    => __( 'Email Template', 'give' ),
534
-							'desc'    => __( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ),
533
+							'name'    => __('Email Template', 'give'),
534
+							'desc'    => __('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'),
535 535
 							'type'    => 'select',
536 536
 							'options' => give_get_email_templates(),
537 537
 						),
538 538
 						array(
539 539
 							'id'   => 'email_logo',
540
-							'name' => __( 'Logo', 'give' ),
541
-							'desc' => __( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
540
+							'name' => __('Logo', 'give'),
541
+							'desc' => __('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'),
542 542
 							'type' => 'file',
543 543
 						),
544 544
 						array(
545 545
 							'id'      => 'from_name',
546
-							'name'    => __( 'From Name', 'give' ),
547
-							'desc'    => __( 'The name that appears in the "From" field in donation receipt emails.', 'give' ),
548
-							'default' => get_bloginfo( 'name' ),
546
+							'name'    => __('From Name', 'give'),
547
+							'desc'    => __('The name that appears in the "From" field in donation receipt emails.', 'give'),
548
+							'default' => get_bloginfo('name'),
549 549
 							'type'    => 'text',
550 550
 						),
551 551
 						array(
552 552
 							'id'      => 'from_email',
553
-							'name'    => __( 'From Email', 'give' ),
554
-							'desc'    => __( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ),
555
-							'default' => get_bloginfo( 'admin_email' ),
553
+							'name'    => __('From Email', 'give'),
554
+							'desc'    => __('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'),
555
+							'default' => get_bloginfo('admin_email'),
556 556
 							'type'    => 'text',
557 557
 						),
558 558
 						array(
559
-							'name' => __( 'Donation Receipt', 'give' ),
559
+							'name' => __('Donation Receipt', 'give'),
560 560
 							'desc' => '',
561 561
 							'id'   => 'give_title_email_settings_2',
562 562
 							'type' => 'give_title',
563 563
 						),
564 564
 						array(
565 565
 							'id'      => 'donation_subject',
566
-							'name'    => __( 'Donation Email Subject', 'give' ),
567
-							'desc'    => __( 'Enter the subject line for the donation receipt email.', 'give' ),
568
-							'default' => esc_attr__( 'Donation Receipt', 'give' ),
566
+							'name'    => __('Donation Email Subject', 'give'),
567
+							'desc'    => __('Enter the subject line for the donation receipt email.', 'give'),
568
+							'default' => esc_attr__('Donation Receipt', 'give'),
569 569
 							'type'    => 'text',
570 570
 						),
571 571
 						array(
572 572
 							'id'      => 'donation_receipt',
573
-							'name'    => __( 'Donation Receipt', 'give' ),
573
+							'name'    => __('Donation Receipt', 'give'),
574 574
 							'desc'    => sprintf(
575 575
 								/* translators: %s: emails tags list */
576
-								__( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give' ),
577
-								'<br/>' . give_get_emails_tags_list()
576
+								__('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give'),
577
+								'<br/>'.give_get_emails_tags_list()
578 578
 							),
579 579
 							'type'    => 'wysiwyg',
580 580
 							'default' => give_get_default_donation_receipt_email(),
581 581
 						),
582 582
 						array(
583
-							'name' => __( 'New Donation Notification', 'give' ),
583
+							'name' => __('New Donation Notification', 'give'),
584 584
 							'desc' => '',
585 585
 							'id'   => 'give_title_email_settings_3',
586 586
 							'type' => 'give_title',
587 587
 						),
588 588
 						array(
589 589
 							'id'      => 'donation_notification_subject',
590
-							'name'    => __( 'Donation Notification Subject', 'give' ),
591
-							'desc'    => __( 'Enter the subject line for the donation notification email.', 'give' ),
590
+							'name'    => __('Donation Notification Subject', 'give'),
591
+							'desc'    => __('Enter the subject line for the donation notification email.', 'give'),
592 592
 							'type'    => 'text',
593
-							'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ),
593
+							'default' => esc_attr__('New Donation - #{payment_id}', 'give'),
594 594
 						),
595 595
 						array(
596 596
 							'id'      => 'donation_notification',
597
-							'name'    => __( 'Donation Notification', 'give' ),
597
+							'name'    => __('Donation Notification', 'give'),
598 598
 							'desc'    => sprintf(
599 599
 								/* translators: %s: emails tags list */
600
-								__( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give' ),
601
-								'<br/>' . give_get_emails_tags_list()
600
+								__('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give'),
601
+								'<br/>'.give_get_emails_tags_list()
602 602
 							),
603 603
 							'type'    => 'wysiwyg',
604 604
 							'default' => give_get_default_donation_notification_email(),
605 605
 						),
606 606
 						array(
607 607
 							'id'      => 'admin_notice_emails',
608
-							'name'    => __( 'Donation Notification Emails', 'give' ),
609
-							'desc'    => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ),
608
+							'name'    => __('Donation Notification Emails', 'give'),
609
+							'desc'    => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'),
610 610
 							'type'    => 'textarea',
611
-							'default' => get_bloginfo( 'admin_email' ),
611
+							'default' => get_bloginfo('admin_email'),
612 612
 						),
613 613
 						array(
614 614
 							'id'   => 'disable_admin_notices',
615
-							'name' => __( 'Disable Admin Notifications', 'give' ),
616
-							'desc' => __( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ),
615
+							'name' => __('Disable Admin Notifications', 'give'),
616
+							'desc' => __('Check this box if you do not want to receive emails when new donations are made.', 'give'),
617 617
 							'type' => 'checkbox',
618 618
 						),
619 619
 					)
@@ -622,99 +622,99 @@  discard block
 block discarded – undo
622 622
 			/** Extension Settings */
623 623
 			'addons'      => array(
624 624
 				'id'         => 'addons',
625
-				'give_title' => __( 'Give Add-ons Settings', 'give' ),
626
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
627
-				'fields'     => apply_filters( 'give_settings_addons', array()
625
+				'give_title' => __('Give Add-ons Settings', 'give'),
626
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
627
+				'fields'     => apply_filters('give_settings_addons', array()
628 628
 				),
629 629
 			),
630 630
 			/** Licenses Settings */
631 631
 			'licenses'    => array(
632 632
 				'id'         => 'licenses',
633
-				'give_title' => __( 'Give Licenses', 'give' ),
634
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
635
-				'fields'     => apply_filters( 'give_settings_licenses', array()
633
+				'give_title' => __('Give Licenses', 'give'),
634
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
635
+				'fields'     => apply_filters('give_settings_licenses', array()
636 636
 				),
637 637
 			),
638 638
 			/** Advanced Options */
639 639
 			'advanced'    => array(
640 640
 				'id'         => 'advanced_options',
641
-				'give_title' => __( 'Advanced Options', 'give' ),
642
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
643
-				'fields'     => apply_filters( 'give_settings_advanced', array(
641
+				'give_title' => __('Advanced Options', 'give'),
642
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
643
+				'fields'     => apply_filters('give_settings_advanced', array(
644 644
 						array(
645
-							'name' => __( 'Access Control', 'give' ),
645
+							'name' => __('Access Control', 'give'),
646 646
 							'desc' => '',
647 647
 							'id'   => 'give_title_session_control_1',
648 648
 							'type' => 'give_title',
649 649
 						),
650 650
 						array(
651 651
 							'id'      => 'session_lifetime',
652
-							'name'    => __( 'Session Lifetime', 'give' ),
653
-							'desc'    => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ),
652
+							'name'    => __('Session Lifetime', 'give'),
653
+							'desc'    => __('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'),
654 654
 							'type'    => 'select',
655 655
 							'options' => array(
656
-								'86400'  => __( '24 Hours', 'give' ),
657
-								'172800' => __( '48 Hours', 'give' ),
658
-								'259200' => __( '72 Hours', 'give' ),
659
-								'604800' => __( '1 Week', 'give' ),
656
+								'86400'  => __('24 Hours', 'give'),
657
+								'172800' => __('48 Hours', 'give'),
658
+								'259200' => __('72 Hours', 'give'),
659
+								'604800' => __('1 Week', 'give'),
660 660
 							),
661 661
 						),
662 662
 						array(
663
-							'name' => __( 'Email Access', 'give' ),
664
-							'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
663
+							'name' => __('Email Access', 'give'),
664
+							'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'),
665 665
 							'id'   => 'email_access',
666 666
 							'type' => 'checkbox',
667 667
 						),
668 668
 						array(
669 669
 							'id'      => 'recaptcha_key',
670
-							'name'    => __( 'reCAPTCHA Site Key', 'give' ),
670
+							'name'    => __('reCAPTCHA Site Key', 'give'),
671 671
 							/* translators: %s: https://www.google.com/recaptcha/ */
672
-							'desc'    => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'https://www.google.com/recaptcha/' ) ),
672
+							'desc'    => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('https://www.google.com/recaptcha/')),
673 673
 							'default' => '',
674 674
 							'type'    => 'text',
675 675
 						),
676 676
 						array(
677 677
 							'id'      => 'recaptcha_secret',
678
-							'name'    => __( 'reCAPTCHA Secret Key', 'give' ),
679
-							'desc'    => __( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ),
678
+							'name'    => __('reCAPTCHA Secret Key', 'give'),
679
+							'desc'    => __('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'),
680 680
 							'default' => '',
681 681
 							'type'    => 'text',
682 682
 						),
683 683
 						array(
684
-							'name' => __( 'Data Control', 'give' ),
684
+							'name' => __('Data Control', 'give'),
685 685
 							'desc' => '',
686 686
 							'id'   => 'give_title_data_control_2',
687 687
 							'type' => 'give_title',
688 688
 						),
689 689
 						array(
690
-							'name' => __( 'Remove All Data on Uninstall?', 'give' ),
691
-							'desc' => __( 'When the plugin is deleted, completely remove all Give data.', 'give' ),
690
+							'name' => __('Remove All Data on Uninstall?', 'give'),
691
+							'desc' => __('When the plugin is deleted, completely remove all Give data.', 'give'),
692 692
 							'id'   => 'uninstall_on_delete',
693 693
 							'type' => 'checkbox',
694 694
 						),
695 695
 						array(
696
-							'name' => __( 'Filter Control', 'give' ),
696
+							'name' => __('Filter Control', 'give'),
697 697
 							'desc' => '',
698 698
 							'id'   => 'give_title_filter_control',
699 699
 							'type' => 'give_title',
700 700
 						),
701 701
 						array(
702 702
 							/* translators: %s: the_content */
703
-							'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ),
703
+							'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'),
704 704
 							/* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
705
-							'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
705
+							'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'),
706 706
 							'id'   => 'disable_the_content_filter',
707 707
 							'type' => 'checkbox',
708 708
 						),
709 709
 						array(
710
-							'name' => __( 'Script Loading', 'give' ),
710
+							'name' => __('Script Loading', 'give'),
711 711
 							'desc' => '',
712 712
 							'id'   => 'give_title_script_control',
713 713
 							'type' => 'give_title',
714 714
 						),
715 715
 						array(
716
-							'name' => __( 'Load Scripts in Footer?', 'give' ),
717
-							'desc' => __( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ),
716
+							'name' => __('Load Scripts in Footer?', 'give'),
717
+							'desc' => __('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'),
718 718
 							'id'   => 'scripts_footer',
719 719
 							'type' => 'checkbox',
720 720
 						),
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
 			/** API Settings */
725 725
 			'api'         => array(
726 726
 				'id'         => 'api',
727
-				'give_title' => __( 'API', 'give' ),
728
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
727
+				'give_title' => __('API', 'give'),
728
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
729 729
 				'show_names' => false, // Hide field names on the left
730
-				'fields'     => apply_filters( 'give_settings_system', array(
730
+				'fields'     => apply_filters('give_settings_system', array(
731 731
 						array(
732 732
 							'id'   => 'api',
733
-							'name' => __( 'API', 'give' ),
733
+							'name' => __('API', 'give'),
734 734
 							'type' => 'api',
735 735
 						),
736 736
 					)
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 			/** Licenses Settings */
740 740
 			'system_info' => array(
741 741
 				'id'         => 'system_info',
742
-				'give_title' => __( 'System Info', 'give' ),
743
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
744
-				'fields'     => apply_filters( 'give_settings_system', array(
742
+				'give_title' => __('System Info', 'give'),
743
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
744
+				'fields'     => apply_filters('give_settings_system', array(
745 745
 						array(
746 746
 							'id'   => 'system-info-textarea',
747
-							'name' => __( 'System Info', 'give' ),
748
-							'desc' => __( 'Please copy and paste this information in your ticket when contacting support.', 'give' ),
747
+							'name' => __('System Info', 'give'),
748
+							'desc' => __('Please copy and paste this information in your ticket when contacting support.', 'give'),
749 749
 							'type' => 'system_info',
750 750
 						),
751 751
 					)
@@ -753,15 +753,15 @@  discard block
 block discarded – undo
753 753
 			),
754 754
 		);
755 755
 
756
-		$give_settings = apply_filters( 'give_registered_settings', $give_settings );
756
+		$give_settings = apply_filters('give_registered_settings', $give_settings);
757 757
 
758 758
 		// Return all settings array if no active tab
759
-		if ( empty( $active_tab ) || ! isset( $give_settings[ $active_tab ] ) ) {
759
+		if (empty($active_tab) || ! isset($give_settings[$active_tab])) {
760 760
 			return $give_settings;
761 761
 		}
762 762
 
763 763
 		// Add other tabs and settings fields as needed
764
-		return $give_settings[ $active_tab ];
764
+		return $give_settings[$active_tab];
765 765
 
766 766
 	}
767 767
 
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 */
771 771
 	public function settings_notices() {
772 772
 
773
-		if ( ! isset( $_POST['give_settings_saved'] ) ) {
773
+		if ( ! isset($_POST['give_settings_saved'])) {
774 774
 			return;
775 775
 		}
776 776
 
777
-		add_settings_error( 'give-notices', 'global-settings-updated', __( 'Settings updated.', 'give' ), 'updated' );
777
+		add_settings_error('give-notices', 'global-settings-updated', __('Settings updated.', 'give'), 'updated');
778 778
 
779 779
 	}
780 780
 
@@ -789,14 +789,14 @@  discard block
 block discarded – undo
789 789
 	 * @return mixed         Field value or exception is thrown.
790 790
 	 * @throws Exception     Throws an exception if the field is invalid.
791 791
 	 */
792
-	public function __get( $field ) {
792
+	public function __get($field) {
793 793
 
794 794
 		// Allowed fields to retrieve
795
-		if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) {
795
+		if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) {
796 796
 			return $this->{$field};
797 797
 		}
798 798
 
799
-		throw new Exception( sprintf( __( 'Invalid property: %s', 'give' ), $field ) );
799
+		throw new Exception(sprintf(__('Invalid property: %s', 'give'), $field));
800 800
 	}
801 801
 
802 802
 
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
  *
816 816
  * @return mixed        Option value
817 817
  */
818
-function give_get_option( $key = '', $default = false ) {
818
+function give_get_option($key = '', $default = false) {
819 819
 	$give_options = give_get_settings();
820
-	$value        = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default;
821
-	$value        = apply_filters( 'give_get_option', $value, $key, $default );
820
+	$value        = ! empty($give_options[$key]) ? $give_options[$key] : $default;
821
+	$value        = apply_filters('give_get_option', $value, $key, $default);
822 822
 
823
-	return apply_filters( "give_get_option_{$key}", $value, $key, $default );
823
+	return apply_filters("give_get_option_{$key}", $value, $key, $default);
824 824
 }
825 825
 
826 826
 
@@ -838,33 +838,33 @@  discard block
 block discarded – undo
838 838
  *
839 839
  * @return boolean True if updated, false if not.
840 840
  */
841
-function give_update_option( $key = '', $value = false ) {
841
+function give_update_option($key = '', $value = false) {
842 842
 
843 843
 	// If no key, exit
844
-	if ( empty( $key ) ) {
844
+	if (empty($key)) {
845 845
 		return false;
846 846
 	}
847 847
 
848
-	if ( empty( $value ) ) {
849
-		$remove_option = give_delete_option( $key );
848
+	if (empty($value)) {
849
+		$remove_option = give_delete_option($key);
850 850
 
851 851
 		return $remove_option;
852 852
 	}
853 853
 
854 854
 	// First let's grab the current settings
855
-	$options = get_option( 'give_settings' );
855
+	$options = get_option('give_settings');
856 856
 
857 857
 	// Let's let devs alter that value coming in
858
-	$value = apply_filters( 'give_update_option', $value, $key );
858
+	$value = apply_filters('give_update_option', $value, $key);
859 859
 
860 860
 	// Next let's try to update the value
861
-	$options[ $key ] = $value;
862
-	$did_update      = update_option( 'give_settings', $options );
861
+	$options[$key] = $value;
862
+	$did_update      = update_option('give_settings', $options);
863 863
 
864 864
 	// If it updated, let's update the global variable
865
-	if ( $did_update ) {
865
+	if ($did_update) {
866 866
 		global $give_options;
867
-		$give_options[ $key ] = $value;
867
+		$give_options[$key] = $value;
868 868
 	}
869 869
 
870 870
 	return $did_update;
@@ -883,25 +883,25 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return boolean True if updated, false if not.
885 885
  */
886
-function give_delete_option( $key = '' ) {
886
+function give_delete_option($key = '') {
887 887
 
888 888
 	// If no key, exit
889
-	if ( empty( $key ) ) {
889
+	if (empty($key)) {
890 890
 		return false;
891 891
 	}
892 892
 
893 893
 	// First let's grab the current settings
894
-	$options = get_option( 'give_settings' );
894
+	$options = get_option('give_settings');
895 895
 
896 896
 	// Next let's try to update the value
897
-	if ( isset( $options[ $key ] ) ) {
898
-		unset( $options[ $key ] );
897
+	if (isset($options[$key])) {
898
+		unset($options[$key]);
899 899
 	}
900 900
 
901
-	$did_update = update_option( 'give_settings', $options );
901
+	$did_update = update_option('give_settings', $options);
902 902
 
903 903
 	// If it updated, let's update the global variable
904
-	if ( $did_update ) {
904
+	if ($did_update) {
905 905
 		global $give_options;
906 906
 		$give_options = $options;
907 907
 	}
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
  */
921 921
 function give_get_settings() {
922 922
 
923
-	$settings = get_option( 'give_settings' );
923
+	$settings = get_option('give_settings');
924 924
 
925
-	return (array) apply_filters( 'give_get_settings', $settings );
925
+	return (array) apply_filters('give_get_settings', $settings);
926 926
 
927 927
 }
928 928
 
@@ -940,25 +940,25 @@  discard block
 block discarded – undo
940 940
  *
941 941
  * @return array
942 942
  */
943
-function give_settings_array_insert( $array, $position, $insert ) {
944
-	if ( is_int( $position ) ) {
945
-		array_splice( $array, $position, 0, $insert );
943
+function give_settings_array_insert($array, $position, $insert) {
944
+	if (is_int($position)) {
945
+		array_splice($array, $position, 0, $insert);
946 946
 	} else {
947 947
 
948
-		foreach ( $array as $index => $subarray ) {
949
-			if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) {
948
+		foreach ($array as $index => $subarray) {
949
+			if (isset($subarray['id']) && $subarray['id'] == $position) {
950 950
 				$pos = $index;
951 951
 			}
952 952
 		}
953 953
 
954
-		if ( ! isset( $pos ) ) {
954
+		if ( ! isset($pos)) {
955 955
 			return $array;
956 956
 		}
957 957
 
958 958
 		$array = array_merge(
959
-			array_slice( $array, 0, $pos ),
959
+			array_slice($array, 0, $pos),
960 960
 			$insert,
961
-			array_slice( $array, $pos )
961
+			array_slice($array, $pos)
962 962
 		);
963 963
 	}
964 964
 
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
  *
979 979
  * @return void
980 980
  */
981
-function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) {
981
+function give_enabled_gateways_callback($field_arr, $saved_values = array()) {
982 982
 
983 983
 	$id       = $field_arr['id'];
984
-	$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
984
+	$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
985 985
 
986 986
 	echo '<ul class="give-checklist-fields give-payment-gatways-list">';
987 987
 
988
-	foreach ( $gateways as $key => $option ) :
988
+	foreach ($gateways as $key => $option) :
989 989
 
990
-		if ( is_array( $saved_values ) && array_key_exists( $key, $saved_values ) ) {
990
+		if (is_array($saved_values) && array_key_exists($key, $saved_values)) {
991 991
 			$enabled = '1';
992 992
 		} else {
993 993
 			$enabled = null;
994 994
 		}
995 995
 
996
-		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
997
-		echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>';
996
+		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/>&nbsp;';
997
+		echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>';
998 998
 
999 999
 	endforeach;
1000 1000
 
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
  *
1014 1014
  * @return void
1015 1015
  */
1016
-function give_default_gateway_callback( $field_arr, $saved_value ) {
1016
+function give_default_gateway_callback($field_arr, $saved_value) {
1017 1017
 	$id          = $field_arr['id'];
1018 1018
 	$gateways    = give_get_enabled_payment_gateways();
1019
-	$saved_value = give_get_default_gateway( null );
1019
+	$saved_value = give_get_default_gateway(null);
1020 1020
 
1021
-	echo '<select class="give-select" name="' . $id . '" id="' . $id . '">';
1021
+	echo '<select class="give-select" name="'.$id.'" id="'.$id.'">';
1022 1022
 
1023
-	foreach ( $gateways as $key => $option ) :
1024
-		$selected = isset( $saved_value ) ? selected( $key, $saved_value, false ) : '';
1025
-		echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1023
+	foreach ($gateways as $key => $option) :
1024
+		$selected = isset($saved_value) ? selected($key, $saved_value, false) : '';
1025
+		echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>';
1026 1026
 	endforeach;
1027 1027
 
1028 1028
 	echo '</select>';
@@ -1040,13 +1040,13 @@  discard block
 block discarded – undo
1040 1040
  *
1041 1041
  * @return void
1042 1042
  */
1043
-function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1043
+function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1044 1044
 
1045 1045
 	$id                = $field_type_object->field->args['id'];
1046 1046
 	$title             = $field_type_object->field->args['name'];
1047 1047
 	$field_description = $field_type_object->field->args['desc'];
1048 1048
 
1049
-	echo '<hr>' . $field_description;
1049
+	echo '<hr>'.$field_description;
1050 1050
 
1051 1051
 }
1052 1052
 
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
  *
1062 1062
  * @return void
1063 1063
  */
1064
-function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1064
+function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1065 1065
 
1066 1066
 	$id                = $field_type_object->field->args['id'];
1067 1067
 	$title             = $field_type_object->field->args['name'];
@@ -1080,25 +1080,25 @@  discard block
 block discarded – undo
1080 1080
  * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types
1081 1081
  * @return array An array of options that matches the CMB2 options array
1082 1082
  */
1083
-function give_cmb2_get_post_options( $query_args, $force = false ) {
1083
+function give_cmb2_get_post_options($query_args, $force = false) {
1084 1084
 
1085
-	$post_options = array( '' => '' ); // Blank option
1085
+	$post_options = array('' => ''); // Blank option
1086 1086
 
1087
-	if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) {
1087
+	if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) {
1088 1088
 		return $post_options;
1089 1089
 	}
1090 1090
 
1091
-	$args = wp_parse_args( $query_args, array(
1091
+	$args = wp_parse_args($query_args, array(
1092 1092
 		'post_type'   => 'page',
1093 1093
 		'numberposts' => 10,
1094
-	) );
1094
+	));
1095 1095
 
1096
-	$posts = get_posts( $args );
1096
+	$posts = get_posts($args);
1097 1097
 
1098
-	if ( $posts ) {
1099
-		foreach ( $posts as $post ) {
1098
+	if ($posts) {
1099
+		foreach ($posts as $post) {
1100 1100
 
1101
-			$post_options[ $post->ID ] = $post->post_title;
1101
+			$post_options[$post->ID] = $post->post_title;
1102 1102
 
1103 1103
 		}
1104 1104
 	}
@@ -1124,20 +1124,20 @@  discard block
 block discarded – undo
1124 1124
 	$get_sizes = get_intermediate_image_sizes();
1125 1125
 
1126 1126
 	// check whether intermediate image sizes exist first
1127
-	if ( empty( $get_sizes ) ) {
1128
-		$get_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' );
1127
+	if (empty($get_sizes)) {
1128
+		$get_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
1129 1129
 	}
1130 1130
 
1131
-	foreach ( $get_sizes as $_size ) {
1131
+	foreach ($get_sizes as $_size) {
1132 1132
 
1133
-		if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
1134
-			$sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" );
1135
-		} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
1136
-			$sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height'];
1133
+		if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
1134
+			$sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h");
1135
+		} elseif (isset($_wp_additional_image_sizes[$_size])) {
1136
+			$sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height'];
1137 1137
 		}
1138 1138
 	}
1139 1139
 
1140
-	return apply_filters( 'give_get_featured_image_sizes', $sizes );
1140
+	return apply_filters('give_get_featured_image_sizes', $sizes);
1141 1141
 }
1142 1142
 
1143 1143
 
@@ -1152,18 +1152,18 @@  discard block
 block discarded – undo
1152 1152
  *
1153 1153
  * @return void
1154 1154
  */
1155
-function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1155
+function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1156 1156
 	/* @var CMB2_Types $field_type_object */
1157 1157
 
1158 1158
 	$id                 = $field_type_object->field->args['id'];
1159 1159
 	$field_description  = $field_type_object->field->args['desc'];
1160 1160
 	$license            = $field_type_object->field->args['options']['license'];
1161 1161
 	$license_key        = $escaped_value;
1162
-	$is_license_key     = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) );
1163
-	$is_valid_license   = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) );
1162
+	$is_license_key     = apply_filters('give_is_license_key', (is_object($license) && ! empty($license)));
1163
+	$is_valid_license   = apply_filters('give_is_valid_license', ($is_license_key && property_exists($license, 'license') && 'valid' === $license->license));
1164 1164
 	$shortname          = $field_type_object->field->args['options']['shortname'];
1165 1165
 	$field_classes      = 'regular-text give-license-field';
1166
-	$type               = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password';
1166
+	$type               = empty($escaped_value) || ! $is_valid_license ? 'text' : 'password';
1167 1167
 	$custom_html        = '';
1168 1168
 	$messages           = array();
1169 1169
 	$class              = '';
@@ -1175,135 +1175,135 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
 	// By default query on edd api url will return license object which contain status and message property, this can break below functionality.
1177 1177
 	// To combat that check if status is set to error or not, if yes then set $is_license_key to false.
1178
-	if ( $is_license_key && property_exists( $license, 'status' ) && 'error' === $license->status ) {
1178
+	if ($is_license_key && property_exists($license, 'status') && 'error' === $license->status) {
1179 1179
 		$is_license_key = false;
1180 1180
 	}
1181 1181
 
1182 1182
 	// Check if current license is part of subscription or not.
1183
-	$subscriptions = get_option( 'give_subscriptions' );
1183
+	$subscriptions = get_option('give_subscriptions');
1184 1184
 
1185
-	if ( $is_license_key && $subscriptions ) {
1186
-		foreach ( $subscriptions as $subscription ) {
1187
-			if ( in_array( $license_key, $subscription['licenses'] ) ) {
1185
+	if ($is_license_key && $subscriptions) {
1186
+		foreach ($subscriptions as $subscription) {
1187
+			if (in_array($license_key, $subscription['licenses'])) {
1188 1188
 				$is_in_subscription = $subscription['id'];
1189 1189
 				break;
1190 1190
 			}
1191 1191
 		}
1192 1192
 	}
1193 1193
 
1194
-	if ( $is_license_key ) {
1195
-		if ( $is_in_subscription ) {
1196
-			$subscription_expires = strtotime( $subscriptions[ $is_in_subscription ]['expires'] );
1197
-			$subscription_status  = __( 'renew', 'give' );
1194
+	if ($is_license_key) {
1195
+		if ($is_in_subscription) {
1196
+			$subscription_expires = strtotime($subscriptions[$is_in_subscription]['expires']);
1197
+			$subscription_status  = __('renew', 'give');
1198 1198
 
1199
-			if ( ( 'active' !== $subscriptions[ $is_in_subscription ]['status'] ) ) {
1200
-				$subscription_status = __( 'expire', 'give' );
1199
+			if (('active' !== $subscriptions[$is_in_subscription]['status'])) {
1200
+				$subscription_status = __('expire', 'give');
1201 1201
 			}
1202 1202
 
1203
-			if ( $subscription_expires < current_time( 'timestamp', 1 ) ) {
1204
-				$messages[]     = sprintf(
1205
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give' ),
1206
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1207
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1208
-					$checkout_page_link . '?edd_license_key=' . $subscriptions[ $is_in_subscription ]['license_key'] . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1203
+			if ($subscription_expires < current_time('timestamp', 1)) {
1204
+				$messages[] = sprintf(
1205
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give'),
1206
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1207
+					$subscriptions[$is_in_subscription]['payment_id'],
1208
+					$checkout_page_link.'?edd_license_key='.$subscriptions[$is_in_subscription]['license_key'].'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1209 1209
 				);
1210 1210
 				$license_status = 'license-expired';
1211
-			} elseif ( strtotime( '- 7 days', $subscription_expires ) < current_time( 'timestamp', 1 ) ) {
1211
+			} elseif (strtotime('- 7 days', $subscription_expires) < current_time('timestamp', 1)) {
1212 1212
 				$messages[]     = sprintf(
1213
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give' ),
1214
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1215
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1213
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give'),
1214
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1215
+					$subscriptions[$is_in_subscription]['payment_id'],
1216 1216
 					$subscription_status,
1217
-					human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscriptions[ $is_in_subscription ]['expires'] ) )
1217
+					human_time_diff(current_time('timestamp', 1), strtotime($subscriptions[$is_in_subscription]['expires']))
1218 1218
 				);
1219 1219
 				$license_status = 'license-expires-soon';
1220 1220
 			} else {
1221 1221
 				$messages[]     = sprintf(
1222
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give' ),
1223
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1224
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1222
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give'),
1223
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1224
+					$subscriptions[$is_in_subscription]['payment_id'],
1225 1225
 					$subscription_status,
1226
-					date_i18n( get_option( 'date_format' ), strtotime( $subscriptions[ $is_in_subscription ]['expires'], current_time( 'timestamp' ) ) )
1226
+					date_i18n(get_option('date_format'), strtotime($subscriptions[$is_in_subscription]['expires'], current_time('timestamp')))
1227 1227
 				);
1228 1228
 				$license_status = 'license-expiration-date';
1229 1229
 			}
1230
-		} elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) {
1230
+		} elseif (empty($license->success) && property_exists($license, 'error')) {
1231 1231
 
1232 1232
 			// activate_license 'invalid' on anything other than valid, so if there was an error capture it
1233
-			switch ( $license->error ) {
1233
+			switch ($license->error) {
1234 1234
 				case 'expired' :
1235 1235
 					$class          = $license->error;
1236 1236
 					$messages[]     = sprintf(
1237
-						__( 'Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ),
1238
-						date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1239
-						$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1237
+						__('Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give'),
1238
+						date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1239
+						$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1240 1240
 					);
1241
-					$license_status = 'license-' . $class;
1241
+					$license_status = 'license-'.$class;
1242 1242
 					break;
1243 1243
 
1244 1244
 				case 'missing' :
1245 1245
 					$class          = $license->error;
1246 1246
 					$messages[]     = sprintf(
1247
-						__( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give' ),
1248
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1247
+						__('Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give'),
1248
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1249 1249
 					);
1250
-					$license_status = 'license-' . $class;
1250
+					$license_status = 'license-'.$class;
1251 1251
 					break;
1252 1252
 
1253 1253
 				case 'invalid' :
1254 1254
 					$class          = $license->error;
1255 1255
 					$messages[]     = sprintf(
1256
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1256
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1257 1257
 						$addon_name,
1258
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1258
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1259 1259
 					);
1260
-					$license_status = 'license-' . $class;
1260
+					$license_status = 'license-'.$class;
1261 1261
 					break;
1262 1262
 
1263 1263
 				case 'site_inactive' :
1264 1264
 					$class          = $license->error;
1265 1265
 					$messages[]     = sprintf(
1266
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1266
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1267 1267
 						$addon_name,
1268
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1268
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1269 1269
 					);
1270
-					$license_status = 'license-' . $class;
1270
+					$license_status = 'license-'.$class;
1271 1271
 					break;
1272 1272
 
1273 1273
 				case 'item_name_mismatch' :
1274 1274
 					$class          = $license->error;
1275
-					$messages[]     = sprintf( __( 'This license %1$s does not belong to %2$s.', 'give' ), $license_key, $addon_name );
1276
-					$license_status = 'license-' . $class;
1275
+					$messages[]     = sprintf(__('This license %1$s does not belong to %2$s.', 'give'), $license_key, $addon_name);
1276
+					$license_status = 'license-'.$class;
1277 1277
 					break;
1278 1278
 
1279 1279
 				case 'no_activations_left':
1280 1280
 					$class          = $license->error;
1281
-					$messages[]     = sprintf( __( 'Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give' ), $account_page_link );
1282
-					$license_status = 'license-' . $class;
1281
+					$messages[]     = sprintf(__('Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give'), $account_page_link);
1282
+					$license_status = 'license-'.$class;
1283 1283
 					break;
1284 1284
 			}
1285 1285
 		} else {
1286
-			switch ( $license->license ) {
1286
+			switch ($license->license) {
1287 1287
 				case 'valid' :
1288 1288
 				default:
1289 1289
 					$class      = 'valid';
1290
-					$now        = current_time( 'timestamp' );
1291
-					$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
1290
+					$now        = current_time('timestamp');
1291
+					$expiration = strtotime($license->expires, current_time('timestamp'));
1292 1292
 
1293
-					if ( 'lifetime' === $license->expires ) {
1294
-						$messages[]     = __( 'License key never expires.', 'give' );
1293
+					if ('lifetime' === $license->expires) {
1294
+						$messages[]     = __('License key never expires.', 'give');
1295 1295
 						$license_status = 'license-lifetime-notice';
1296
-					} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
1296
+					} elseif ($expiration > $now && $expiration - $now < (DAY_IN_SECONDS * 30)) {
1297 1297
 						$messages[]     = sprintf(
1298
-							__( 'Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give' ),
1299
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1300
-							$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1298
+							__('Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give'),
1299
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1300
+							$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1301 1301
 						);
1302 1302
 						$license_status = 'license-expires-soon';
1303 1303
 					} else {
1304 1304
 						$messages[]     = sprintf(
1305
-							__( 'Your license key expires on %s.', 'give' ),
1306
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
1305
+							__('Your license key expires on %s.', 'give'),
1306
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp')))
1307 1307
 						);
1308 1308
 						$license_status = 'license-expiration-date';
1309 1309
 					}
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 			}
1312 1312
 		}
1313 1313
 	} else {
1314
-		$messages[]     = sprintf(
1315
-			__( 'To receive updates, please enter your valid %s license key.', 'give' ),
1314
+		$messages[] = sprintf(
1315
+			__('To receive updates, please enter your valid %s license key.', 'give'),
1316 1316
 			$addon_name
1317 1317
 		);
1318 1318
 		$license_status = 'inactive';
1319 1319
 	}
1320 1320
 
1321 1321
 	// Add class for input field if license is active.
1322
-	if ( $is_valid_license ) {
1322
+	if ($is_valid_license) {
1323 1323
 		$field_classes .= ' give-license-active';
1324 1324
 	}
1325 1325
 
@@ -1327,33 +1327,33 @@  discard block
 block discarded – undo
1327 1327
 	$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\">";
1328 1328
 
1329 1329
 	// If license is active so show deactivate button.
1330
-	if ( $is_valid_license ) {
1330
+	if ($is_valid_license) {
1331 1331
 		// Get input field html.
1332 1332
 		$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">";
1333 1333
 
1334
-		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>';
1334
+		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="'.$id.'_deactivate" value="'.esc_attr__('Deactivate License', 'give').'"/>';
1335 1335
 
1336 1336
 	}
1337 1337
 
1338 1338
 	// Field description.
1339
-	$custom_html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>';
1339
+	$custom_html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>';
1340 1340
 
1341 1341
 	// If no messages found then inform user that to get updated in future register yourself.
1342
-	if ( empty( $messages ) ) {
1343
-		$messages[] = apply_filters( "{$shortname}_default_addon_notice", __( 'To receive updates, please enter your valid license key.', 'give' ) );
1342
+	if (empty($messages)) {
1343
+		$messages[] = apply_filters("{$shortname}_default_addon_notice", __('To receive updates, please enter your valid license key.', 'give'));
1344 1344
 	}
1345 1345
 
1346
-	foreach ( $messages as $message ) {
1347
-		$custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">';
1348
-		$custom_html .= '<p>' . $message . '</p>';
1346
+	foreach ($messages as $message) {
1347
+		$custom_html .= '<div class="give-license-status-notice give-'.$license_status.'">';
1348
+		$custom_html .= '<p>'.$message.'</p>';
1349 1349
 		$custom_html .= '</div>';
1350 1350
 	}
1351 1351
 
1352 1352
 	// Field html.
1353
-	$custom_html = apply_filters( 'give_license_key_field_html', $input_field_html . $custom_html, $field_type_object );
1353
+	$custom_html = apply_filters('give_license_key_field_html', $input_field_html.$custom_html, $field_type_object);
1354 1354
 
1355 1355
 	// Nonce.
1356
-	wp_nonce_field( $id . '-nonce', $id . '-nonce' );
1356
+	wp_nonce_field($id.'-nonce', $id.'-nonce');
1357 1357
 
1358 1358
 	// Print field html.
1359 1359
 	echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>";
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
  */
1369 1369
 function give_api_callback() {
1370 1370
 
1371
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
1371
+	if ( ! current_user_can('manage_give_settings')) {
1372 1372
 		return;
1373 1373
 	}
1374 1374
 
@@ -1377,9 +1377,9 @@  discard block
 block discarded – undo
1377 1377
 	 *
1378 1378
 	 * @since 1.0
1379 1379
 	 */
1380
-	do_action( 'give_tools_api_keys_before' );
1380
+	do_action('give_tools_api_keys_before');
1381 1381
 
1382
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
1382
+	require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
1383 1383
 
1384 1384
 	$api_keys_table = new Give_API_Keys_Table();
1385 1385
 	$api_keys_table->prepare_items();
@@ -1388,9 +1388,9 @@  discard block
 block discarded – undo
1388 1388
 	<span class="cmb2-metabox-description api-description">
1389 1389
 		<?php echo sprintf(
1390 1390
 			/* translators: 1: http://docs.givewp.com/api 2: http://docs.givewp.com/addon-zapier */
1391
-			__( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ),
1392
-			esc_url( 'http://docs.givewp.com/api' ),
1393
-			esc_url( 'http://docs.givewp.com/addon-zapier' )
1391
+			__('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'),
1392
+			esc_url('http://docs.givewp.com/api'),
1393
+			esc_url('http://docs.givewp.com/addon-zapier')
1394 1394
 		); ?>
1395 1395
 	</span>
1396 1396
 	<?php
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
1400 1400
 	 *
1401 1401
 	 * @since 1.0
1402 1402
 	 */
1403
-	do_action( 'give_tools_api_keys_after' );
1403
+	do_action('give_tools_api_keys_after');
1404 1404
 }
1405 1405
 
1406
-add_action( 'give_settings_tab_api_keys', 'give_api_callback' );
1406
+add_action('give_settings_tab_api_keys', 'give_api_callback');
1407 1407
 
1408 1408
 /**
1409 1409
  * Hook Callback
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
  *
1417 1417
  * @return void
1418 1418
  */
1419
-function give_hook_callback( $args ) {
1419
+function give_hook_callback($args) {
1420 1420
 
1421 1421
 	$id = $args['id'];
1422 1422
 
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 	 *
1426 1426
 	 * @since 1.0
1427 1427
 	 */
1428
-	do_action( "give_{$id}" );
1428
+	do_action("give_{$id}");
1429 1429
 
1430 1430
 }
1431 1431
 
@@ -1440,19 +1440,19 @@  discard block
 block discarded – undo
1440 1440
  *
1441 1441
  * @return bool
1442 1442
  */
1443
-function give_is_setting_enabled( $value, $compare_with = null ) {
1444
-	if ( ! is_null( $compare_with ) ) {
1443
+function give_is_setting_enabled($value, $compare_with = null) {
1444
+	if ( ! is_null($compare_with)) {
1445 1445
 
1446
-		if ( is_array( $compare_with ) ) {
1446
+		if (is_array($compare_with)) {
1447 1447
 			// Output.
1448
-			return in_array( $value, $compare_with );
1448
+			return in_array($value, $compare_with);
1449 1449
 		}
1450 1450
 
1451 1451
 		// Output.
1452
-		return ( $value === $compare_with );
1452
+		return ($value === $compare_with);
1453 1453
 	}
1454 1454
 
1455 1455
 	// Backward compatibility: From version 1.8 most of setting is modified to enabled/disabled
1456 1456
 	// Output.
1457
-	return ( in_array( $value, array( 'enabled', 'on', 'yes' ) ) ? true : false );
1457
+	return (in_array($value, array('enabled', 'on', 'yes')) ? true : false);
1458 1458
 }
Please login to merge, or discard this patch.
includes/class-give-customer.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 * @access public
890 890
 	 *
891 891
 	 * @param  string $meta_key Metadata name. Default is empty.
892
-	 * @param  mixed $meta_value Metadata value.
892
+	 * @param  string $meta_value Metadata value.
893 893
 	 * @param  bool $unique Optional. Whether the same key should not be added. Default is false.
894 894
 	 *
895 895
 	 * @return bool               False for failure. True for success.
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 * @access public
922 922
 	 *
923 923
 	 * @param  string $meta_key Metadata name. Default is empty.
924
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
924
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
925 925
 	 *
926 926
 	 * @return bool               False for failure. True for success.
927 927
 	 */
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 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
 
@@ -144,32 +144,32 @@  discard block
 block discarded – undo
144 144
 	 * @param  bool $_id_or_email
145 145
 	 * @param  bool $by_user_id
146 146
 	 */
147
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
147
+	public function __construct($_id_or_email = false, $by_user_id = false) {
148 148
 
149 149
 		$this->db = new Give_DB_Customers;
150 150
 
151 151
 		if (
152 152
 			false === $_id_or_email
153
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
153
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
154 154
 		) {
155 155
 			return false;
156 156
 		}
157 157
 
158
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
158
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
159 159
 
160
-		if ( is_numeric( $_id_or_email ) ) {
160
+		if (is_numeric($_id_or_email)) {
161 161
 			$field = $by_user_id ? 'user_id' : 'id';
162 162
 		} else {
163 163
 			$field = 'email';
164 164
 		}
165 165
 
166
-		$customer = $this->db->get_customer_by( $field, $_id_or_email );
166
+		$customer = $this->db->get_customer_by($field, $_id_or_email);
167 167
 
168
-		if ( empty( $customer ) || ! is_object( $customer ) ) {
168
+		if (empty($customer) || ! is_object($customer)) {
169 169
 			return false;
170 170
 		}
171 171
 
172
-		$this->setup_customer( $customer );
172
+		$this->setup_customer($customer);
173 173
 
174 174
 	}
175 175
 
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return bool             If the setup was successful or not.
187 187
 	 */
188
-	private function setup_customer( $customer ) {
188
+	private function setup_customer($customer) {
189 189
 
190
-		if ( ! is_object( $customer ) ) {
190
+		if ( ! is_object($customer)) {
191 191
 			return false;
192 192
 		}
193 193
 
194
-		foreach ( $customer as $key => $value ) {
194
+		foreach ($customer as $key => $value) {
195 195
 
196
-			switch ( $key ) {
196
+			switch ($key) {
197 197
 
198 198
 				case 'notes':
199 199
 					$this->$key = $this->get_notes();
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 		}
208 208
 
209 209
 		// Get donor's all email including primary email.
210
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
211
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
210
+		$this->emails = (array) $this->get_meta('additional_email', false);
211
+		$this->emails = array('primary' => $this->email) + $this->emails;
212 212
 
213 213
 		// Customer ID and email are the only things that are necessary, make sure they exist.
214
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
214
+		if ( ! empty($this->id) && ! empty($this->email)) {
215 215
 			return true;
216 216
 		}
217 217
 
@@ -225,16 +225,16 @@  discard block
 block discarded – undo
225 225
 	 * @since  1.0
226 226
 	 * @access public
227 227
 	 */
228
-	public function __get( $key ) {
228
+	public function __get($key) {
229 229
 
230
-		if ( method_exists( $this, 'get_' . $key ) ) {
230
+		if (method_exists($this, 'get_'.$key)) {
231 231
 
232
-			return call_user_func( array( $this, 'get_' . $key ) );
232
+			return call_user_func(array($this, 'get_'.$key));
233 233
 
234 234
 		} else {
235 235
 
236 236
 			/* translators: %s: property key */
237
-			return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
237
+			return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
238 238
 
239 239
 		}
240 240
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return bool|int    False if not a valid creation, customer ID if user is found or valid creation.
252 252
 	 */
253
-	public function create( $data = array() ) {
253
+	public function create($data = array()) {
254 254
 
255
-		if ( $this->id != 0 || empty( $data ) ) {
255
+		if ($this->id != 0 || empty($data)) {
256 256
 			return false;
257 257
 		}
258 258
 
@@ -260,15 +260,15 @@  discard block
 block discarded – undo
260 260
 			'payment_ids' => '',
261 261
 		);
262 262
 
263
-		$args = wp_parse_args( $data, $defaults );
264
-		$args = $this->sanitize_columns( $args );
263
+		$args = wp_parse_args($data, $defaults);
264
+		$args = $this->sanitize_columns($args);
265 265
 
266
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
266
+		if (empty($args['email']) || ! is_email($args['email'])) {
267 267
 			return false;
268 268
 		}
269 269
 
270
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
271
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
270
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
271
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
272 272
 		}
273 273
 
274 274
 		/**
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 		 *
279 279
 		 * @param array $args Customer attributes.
280 280
 		 */
281
-		do_action( 'give_customer_pre_create', $args );
281
+		do_action('give_customer_pre_create', $args);
282 282
 
283 283
 		$created = false;
284 284
 
285 285
 		// The DB class 'add' implies an update if the customer being asked to be created already exists
286
-		if ( $this->db->add( $data ) ) {
286
+		if ($this->db->add($data)) {
287 287
 
288 288
 			// We've successfully added/updated the customer, reset the class vars with the new data
289
-			$customer = $this->db->get_customer_by( 'email', $args['email'] );
289
+			$customer = $this->db->get_customer_by('email', $args['email']);
290 290
 
291 291
 			// Setup the customer data with the values from DB
292
-			$this->setup_customer( $customer );
292
+			$this->setup_customer($customer);
293 293
 
294 294
 			$created = $this->id;
295 295
 		}
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		 *                          customer ID if user is found or valid creation.
304 304
 		 * @param array $args Customer attributes.
305 305
 		 */
306
-		do_action( 'give_customer_post_create', $created, $args );
306
+		do_action('give_customer_post_create', $created, $args);
307 307
 
308 308
 		return $created;
309 309
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @return bool        If the update was successful or not.
321 321
 	 */
322
-	public function update( $data = array() ) {
322
+	public function update($data = array()) {
323 323
 
324
-		if ( empty( $data ) ) {
324
+		if (empty($data)) {
325 325
 			return false;
326 326
 		}
327 327
 
328
-		$data = $this->sanitize_columns( $data );
328
+		$data = $this->sanitize_columns($data);
329 329
 
330 330
 		/**
331 331
 		 * Fires before updating customers.
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 		 * @param int $customer_id Customer id.
336 336
 		 * @param array $data Customer attributes.
337 337
 		 */
338
-		do_action( 'give_customer_pre_update', $this->id, $data );
338
+		do_action('give_customer_pre_update', $this->id, $data);
339 339
 
340 340
 		$updated = false;
341 341
 
342
-		if ( $this->db->update( $this->id, $data ) ) {
342
+		if ($this->db->update($this->id, $data)) {
343 343
 
344
-			$customer = $this->db->get_customer_by( 'id', $this->id );
345
-			$this->setup_customer( $customer );
344
+			$customer = $this->db->get_customer_by('id', $this->id);
345
+			$this->setup_customer($customer);
346 346
 
347 347
 			$updated = true;
348 348
 		}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		 * @param int $customer_id Customer id.
357 357
 		 * @param array $data Customer attributes.
358 358
 		 */
359
-		do_action( 'give_customer_post_update', $updated, $this->id, $data );
359
+		do_action('give_customer_post_update', $updated, $this->id, $data);
360 360
 
361 361
 		return $updated;
362 362
 	}
@@ -374,27 +374,27 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @return bool            If the attachment was successfuly.
376 376
 	 */
377
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
377
+	public function attach_payment($payment_id = 0, $update_stats = true) {
378 378
 
379
-		if ( empty( $payment_id ) ) {
379
+		if (empty($payment_id)) {
380 380
 			return false;
381 381
 		}
382 382
 
383
-		if ( empty( $this->payment_ids ) ) {
383
+		if (empty($this->payment_ids)) {
384 384
 
385 385
 			$new_payment_ids = $payment_id;
386 386
 
387 387
 		} else {
388 388
 
389
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
389
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
390 390
 
391
-			if ( in_array( $payment_id, $payment_ids ) ) {
391
+			if (in_array($payment_id, $payment_ids)) {
392 392
 				$update_stats = false;
393 393
 			}
394 394
 
395 395
 			$payment_ids[] = $payment_id;
396 396
 
397
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
397
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
398 398
 
399 399
 		}
400 400
 
@@ -406,20 +406,20 @@  discard block
 block discarded – undo
406 406
 		 * @param int $payment_id Payment id.
407 407
 		 * @param int $customer_id Customer id.
408 408
 		 */
409
-		do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id );
409
+		do_action('give_customer_pre_attach_payment', $payment_id, $this->id);
410 410
 
411
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
411
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
412 412
 
413
-		if ( $payment_added ) {
413
+		if ($payment_added) {
414 414
 
415 415
 			$this->payment_ids = $new_payment_ids;
416 416
 
417 417
 			// We added this payment successfully, increment the stats
418
-			if ( $update_stats ) {
419
-				$payment_amount = give_get_payment_amount( $payment_id );
418
+			if ($update_stats) {
419
+				$payment_amount = give_get_payment_amount($payment_id);
420 420
 
421
-				if ( ! empty( $payment_amount ) ) {
422
-					$this->increase_value( $payment_amount );
421
+				if ( ! empty($payment_amount)) {
422
+					$this->increase_value($payment_amount);
423 423
 				}
424 424
 
425 425
 				$this->increase_purchase_count();
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		 * @param int $payment_id Payment id.
436 436
 		 * @param int $customer_id Customer id.
437 437
 		 */
438
-		do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id );
438
+		do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id);
439 439
 
440 440
 		return $payment_added;
441 441
 	}
@@ -453,33 +453,33 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return boolean               If the removal was successful.
455 455
 	 */
456
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
456
+	public function remove_payment($payment_id = 0, $update_stats = true) {
457 457
 
458
-		if ( empty( $payment_id ) ) {
458
+		if (empty($payment_id)) {
459 459
 			return false;
460 460
 		}
461 461
 
462
-		$payment = new Give_Payment( $payment_id );
462
+		$payment = new Give_Payment($payment_id);
463 463
 
464
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
464
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
465 465
 			$update_stats = false;
466 466
 		}
467 467
 
468 468
 		$new_payment_ids = '';
469 469
 
470
-		if ( ! empty( $this->payment_ids ) ) {
470
+		if ( ! empty($this->payment_ids)) {
471 471
 
472
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
472
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
473 473
 
474
-			$pos = array_search( $payment_id, $payment_ids );
475
-			if ( false === $pos ) {
474
+			$pos = array_search($payment_id, $payment_ids);
475
+			if (false === $pos) {
476 476
 				return false;
477 477
 			}
478 478
 
479
-			unset( $payment_ids[ $pos ] );
480
-			$payment_ids = array_filter( $payment_ids );
479
+			unset($payment_ids[$pos]);
480
+			$payment_ids = array_filter($payment_ids);
481 481
 
482
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
482
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
483 483
 
484 484
 		}
485 485
 
@@ -491,20 +491,20 @@  discard block
 block discarded – undo
491 491
 		 * @param int $payment_id Payment id.
492 492
 		 * @param int $customer_id Customer id.
493 493
 		 */
494
-		do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id );
494
+		do_action('give_customer_pre_remove_payment', $payment_id, $this->id);
495 495
 
496
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
496
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
497 497
 
498
-		if ( $payment_removed ) {
498
+		if ($payment_removed) {
499 499
 
500 500
 			$this->payment_ids = $new_payment_ids;
501 501
 
502
-			if ( $update_stats ) {
502
+			if ($update_stats) {
503 503
 				// We removed this payment successfully, decrement the stats
504
-				$payment_amount = give_get_payment_amount( $payment_id );
504
+				$payment_amount = give_get_payment_amount($payment_id);
505 505
 
506
-				if ( ! empty( $payment_amount ) ) {
507
-					$this->decrease_value( $payment_amount );
506
+				if ( ! empty($payment_amount)) {
507
+					$this->decrease_value($payment_amount);
508 508
 				}
509 509
 
510 510
 				$this->decrease_purchase_count();
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 		 * @param int $payment_id Payment id.
521 521
 		 * @param int $customer_id Customer id.
522 522
 		 */
523
-		do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id );
523
+		do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id);
524 524
 
525 525
 		return $payment_removed;
526 526
 
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
 	 *
537 537
 	 * @return int        The donation count.
538 538
 	 */
539
-	public function increase_purchase_count( $count = 1 ) {
539
+	public function increase_purchase_count($count = 1) {
540 540
 
541 541
 		// Make sure it's numeric and not negative.
542
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
542
+		if ( ! is_numeric($count) || $count != absint($count)) {
543 543
 			return false;
544 544
 		}
545 545
 
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 		 * @param int $count The number to increase by.
554 554
 		 * @param int $customer_id Customer id.
555 555
 		 */
556
-		do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id );
556
+		do_action('give_customer_pre_increase_purchase_count', $count, $this->id);
557 557
 
558
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
558
+		if ($this->update(array('purchase_count' => $new_total))) {
559 559
 			$this->purchase_count = $new_total;
560 560
 		}
561 561
 
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		 * @param int $count The number increased by.
569 569
 		 * @param int $customer_id Customer id.
570 570
 		 */
571
-		do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id );
571
+		do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id);
572 572
 
573 573
 		return $this->purchase_count;
574 574
 	}
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
 	 *
584 584
 	 * @return mixed      If successful, the new count, otherwise false.
585 585
 	 */
586
-	public function decrease_purchase_count( $count = 1 ) {
586
+	public function decrease_purchase_count($count = 1) {
587 587
 
588 588
 		// Make sure it's numeric and not negative
589
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
589
+		if ( ! is_numeric($count) || $count != absint($count)) {
590 590
 			return false;
591 591
 		}
592 592
 
593 593
 		$new_total = (int) $this->purchase_count - (int) $count;
594 594
 
595
-		if ( $new_total < 0 ) {
595
+		if ($new_total < 0) {
596 596
 			$new_total = 0;
597 597
 		}
598 598
 
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 		 * @param int $count The number to decrease by.
605 605
 		 * @param int $customer_id Customer id.
606 606
 		 */
607
-		do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id );
607
+		do_action('give_customer_pre_decrease_purchase_count', $count, $this->id);
608 608
 
609
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
609
+		if ($this->update(array('purchase_count' => $new_total))) {
610 610
 			$this->purchase_count = $new_total;
611 611
 		}
612 612
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 		 * @param int $count The number decreased by.
620 620
 		 * @param int $customer_id Customer id.
621 621
 		 */
622
-		do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id );
622
+		do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id);
623 623
 
624 624
 		return $this->purchase_count;
625 625
 	}
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 *
635 635
 	 * @return mixed        If successful, the new value, otherwise false.
636 636
 	 */
637
-	public function increase_value( $value = 0.00 ) {
637
+	public function increase_value($value = 0.00) {
638 638
 
639
-		$new_value = floatval( $this->purchase_value ) + $value;
639
+		$new_value = floatval($this->purchase_value) + $value;
640 640
 
641 641
 		/**
642 642
 		 * Fires before increasing customer lifetime value.
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 		 * @param float $value The value to increase by.
647 647
 		 * @param int $customer_id Customer id.
648 648
 		 */
649
-		do_action( 'give_customer_pre_increase_value', $value, $this->id );
649
+		do_action('give_customer_pre_increase_value', $value, $this->id);
650 650
 
651
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
651
+		if ($this->update(array('purchase_value' => $new_value))) {
652 652
 			$this->purchase_value = $new_value;
653 653
 		}
654 654
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 		 * @param float $value The value increased by.
662 662
 		 * @param int $customer_id Customer id.
663 663
 		 */
664
-		do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id );
664
+		do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id);
665 665
 
666 666
 		return $this->purchase_value;
667 667
 	}
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 	 *
677 677
 	 * @return mixed        If successful, the new value, otherwise false.
678 678
 	 */
679
-	public function decrease_value( $value = 0.00 ) {
679
+	public function decrease_value($value = 0.00) {
680 680
 
681
-		$new_value = floatval( $this->purchase_value ) - $value;
681
+		$new_value = floatval($this->purchase_value) - $value;
682 682
 
683
-		if ( $new_value < 0 ) {
683
+		if ($new_value < 0) {
684 684
 			$new_value = 0.00;
685 685
 		}
686 686
 
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 		 * @param float $value The value to decrease by.
693 693
 		 * @param int $customer_id Customer id.
694 694
 		 */
695
-		do_action( 'give_customer_pre_decrease_value', $value, $this->id );
695
+		do_action('give_customer_pre_decrease_value', $value, $this->id);
696 696
 
697
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
697
+		if ($this->update(array('purchase_value' => $new_value))) {
698 698
 			$this->purchase_value = $new_value;
699 699
 		}
700 700
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		 * @param float $value The value decreased by.
708 708
 		 * @param int $customer_id Customer id.
709 709
 		 */
710
-		do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id );
710
+		do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id);
711 711
 
712 712
 		return $this->purchase_value;
713 713
 	}
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	 *
727 727
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
728 728
 	 */
729
-	public function update_donation_value( $curr_amount, $new_amount ) {
729
+	public function update_donation_value($curr_amount, $new_amount) {
730 730
 		/**
731 731
 		 * Payment total difference value can be:
732 732
 		 *  zero   (in case amount not change)
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 		$payment_total_diff = $new_amount - $curr_amount;
737 737
 
738 738
 		// We do not need to update donation stat if donation did not change.
739
-		if ( ! $payment_total_diff ) {
739
+		if ( ! $payment_total_diff) {
740 740
 			return false;
741 741
 		}
742 742
 
743
-		if ( $payment_total_diff > 0 ) {
744
-			$this->increase_value( $payment_total_diff );
743
+		if ($payment_total_diff > 0) {
744
+			$this->increase_value($payment_total_diff);
745 745
 		} else {
746 746
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
747
-			$this->decrease_value( - $payment_total_diff );
747
+			$this->decrease_value( -$payment_total_diff );
748 748
 		}
749 749
 
750 750
 		return $this->purchase_value;
@@ -761,15 +761,15 @@  discard block
 block discarded – undo
761 761
 	 *
762 762
 	 * @return array       The notes requested.
763 763
 	 */
764
-	public function get_notes( $length = 20, $paged = 1 ) {
764
+	public function get_notes($length = 20, $paged = 1) {
765 765
 
766
-		$length = is_numeric( $length ) ? $length : 20;
767
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
766
+		$length = is_numeric($length) ? $length : 20;
767
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
768 768
 
769 769
 		$all_notes   = $this->get_raw_notes();
770
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
770
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
771 771
 
772
-		$desired_notes = array_slice( $notes_array, $offset, $length );
772
+		$desired_notes = array_slice($notes_array, $offset, $length);
773 773
 
774 774
 		return $desired_notes;
775 775
 
@@ -786,9 +786,9 @@  discard block
 block discarded – undo
786 786
 	public function get_notes_count() {
787 787
 
788 788
 		$all_notes   = $this->get_raw_notes();
789
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
789
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
790 790
 
791
-		return count( $notes_array );
791
+		return count($notes_array);
792 792
 
793 793
 	}
794 794
 
@@ -802,22 +802,22 @@  discard block
 block discarded – undo
802 802
 	 *
803 803
 	 * @return string|boolean The new note if added successfully, false otherwise.
804 804
 	 */
805
-	public function add_note( $note = '' ) {
805
+	public function add_note($note = '') {
806 806
 
807
-		$note = trim( $note );
808
-		if ( empty( $note ) ) {
807
+		$note = trim($note);
808
+		if (empty($note)) {
809 809
 			return false;
810 810
 		}
811 811
 
812 812
 		$notes = $this->get_raw_notes();
813 813
 
814
-		if ( empty( $notes ) ) {
814
+		if (empty($notes)) {
815 815
 			$notes = '';
816 816
 		}
817 817
 
818
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
819
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
820
-		$notes       .= "\n\n" . $new_note;
818
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
819
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
820
+		$notes .= "\n\n".$new_note;
821 821
 
822 822
 		/**
823 823
 		 * Fires before customer note added.
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 		 * @param string $new_note New note to add.
828 828
 		 * @param int $customer_id Customer id.
829 829
 		 */
830
-		do_action( 'give_customer_pre_add_note', $new_note, $this->id );
830
+		do_action('give_customer_pre_add_note', $new_note, $this->id);
831 831
 
832
-		$updated = $this->update( array( 'notes' => $notes ) );
832
+		$updated = $this->update(array('notes' => $notes));
833 833
 
834
-		if ( $updated ) {
834
+		if ($updated) {
835 835
 			$this->notes = $this->get_notes();
836 836
 		}
837 837
 
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 		 * @param string $new_note New note added.
845 845
 		 * @param int $customer_id Customer id.
846 846
 		 */
847
-		do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id );
847
+		do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id);
848 848
 
849 849
 		// Return the formatted note, so we can test, as well as update any displays
850 850
 		return $new_note;
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	 */
862 862
 	private function get_raw_notes() {
863 863
 
864
-		$all_notes = $this->db->get_column( 'notes', $this->id );
864
+		$all_notes = $this->db->get_column('notes', $this->id);
865 865
 
866 866
 		return $all_notes;
867 867
 
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 *
879 879
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
880 880
 	 */
881
-	public function get_meta( $meta_key = '', $single = true ) {
882
-		return Give()->customer_meta->get_meta( $this->id, $meta_key, $single );
881
+	public function get_meta($meta_key = '', $single = true) {
882
+		return Give()->customer_meta->get_meta($this->id, $meta_key, $single);
883 883
 	}
884 884
 
885 885
 	/**
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 	 *
895 895
 	 * @return bool               False for failure. True for success.
896 896
 	 */
897
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
898
-		return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
897
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
898
+		return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
899 899
 	}
900 900
 
901 901
 	/**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 *
911 911
 	 * @return bool               False on failure, true if success.
912 912
 	 */
913
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
914
-		return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
913
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
914
+		return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
915 915
 	}
916 916
 
917 917
 	/**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 *
926 926
 	 * @return bool               False for failure. True for success.
927 927
 	 */
928
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
929
-		return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value );
928
+	public function delete_meta($meta_key = '', $meta_value = '') {
929
+		return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value);
930 930
 	}
931 931
 
932 932
 	/**
@@ -939,51 +939,51 @@  discard block
 block discarded – undo
939 939
 	 *
940 940
 	 * @return array       The sanitized data, based off column defaults.
941 941
 	 */
942
-	private function sanitize_columns( $data ) {
942
+	private function sanitize_columns($data) {
943 943
 
944 944
 		$columns        = $this->db->get_columns();
945 945
 		$default_values = $this->db->get_column_defaults();
946 946
 
947
-		foreach ( $columns as $key => $type ) {
947
+		foreach ($columns as $key => $type) {
948 948
 
949 949
 			// Only sanitize data that we were provided
950
-			if ( ! array_key_exists( $key, $data ) ) {
950
+			if ( ! array_key_exists($key, $data)) {
951 951
 				continue;
952 952
 			}
953 953
 
954
-			switch ( $type ) {
954
+			switch ($type) {
955 955
 
956 956
 				case '%s':
957
-					if ( 'email' == $key ) {
958
-						$data[ $key ] = sanitize_email( $data[ $key ] );
959
-					} elseif ( 'notes' == $key ) {
960
-						$data[ $key ] = strip_tags( $data[ $key ] );
957
+					if ('email' == $key) {
958
+						$data[$key] = sanitize_email($data[$key]);
959
+					} elseif ('notes' == $key) {
960
+						$data[$key] = strip_tags($data[$key]);
961 961
 					} else {
962
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
962
+						$data[$key] = sanitize_text_field($data[$key]);
963 963
 					}
964 964
 					break;
965 965
 
966 966
 				case '%d':
967
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
968
-						$data[ $key ] = $default_values[ $key ];
967
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
968
+						$data[$key] = $default_values[$key];
969 969
 					} else {
970
-						$data[ $key ] = absint( $data[ $key ] );
970
+						$data[$key] = absint($data[$key]);
971 971
 					}
972 972
 					break;
973 973
 
974 974
 				case '%f':
975 975
 					// Convert what was given to a float
976
-					$value = floatval( $data[ $key ] );
976
+					$value = floatval($data[$key]);
977 977
 
978
-					if ( ! is_float( $value ) ) {
979
-						$data[ $key ] = $default_values[ $key ];
978
+					if ( ! is_float($value)) {
979
+						$data[$key] = $default_values[$key];
980 980
 					} else {
981
-						$data[ $key ] = $value;
981
+						$data[$key] = $value;
982 982
 					}
983 983
 					break;
984 984
 
985 985
 				default:
986
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
986
+					$data[$key] = sanitize_text_field($data[$key]);
987 987
 					break;
988 988
 
989 989
 			}
@@ -1003,33 +1003,33 @@  discard block
 block discarded – undo
1003 1003
 	 *
1004 1004
 	 * @return bool            If the email was added successfully
1005 1005
 	 */
1006
-	public function add_email( $email = '', $primary = false ) {
1007
-		if ( ! is_email( $email ) ) {
1006
+	public function add_email($email = '', $primary = false) {
1007
+		if ( ! is_email($email)) {
1008 1008
 			return false;
1009 1009
 		}
1010
-		$existing = new Give_Customer( $email );
1010
+		$existing = new Give_Customer($email);
1011 1011
 
1012
-		if ( $existing->id > 0 ) {
1012
+		if ($existing->id > 0) {
1013 1013
 			// Email address already belongs to another customer
1014 1014
 			return false;
1015 1015
 		}
1016 1016
 
1017
-		if ( email_exists( $email ) ) {
1018
-			$user = get_user_by( 'email', $email );
1019
-			if ( $user->ID != $this->user_id ) {
1017
+		if (email_exists($email)) {
1018
+			$user = get_user_by('email', $email);
1019
+			if ($user->ID != $this->user_id) {
1020 1020
 				return false;
1021 1021
 			}
1022 1022
 		}
1023 1023
 
1024
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1024
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1025 1025
 
1026 1026
 		// Add is used to ensure duplicate emails are not added
1027
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1027
+		$ret = (bool) $this->add_meta('additional_email', $email);
1028 1028
 
1029
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1029
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1030 1030
 
1031
-		if ( $ret && true === $primary ) {
1032
-			$this->set_primary_email( $email );
1031
+		if ($ret && true === $primary) {
1032
+			$this->set_primary_email($email);
1033 1033
 		}
1034 1034
 
1035 1035
 		return $ret;
@@ -1045,16 +1045,16 @@  discard block
 block discarded – undo
1045 1045
 	 *
1046 1046
 	 * @return bool          If the email was removed successfully
1047 1047
 	 */
1048
-	public function remove_email( $email = '' ) {
1049
-		if ( ! is_email( $email ) ) {
1048
+	public function remove_email($email = '') {
1049
+		if ( ! is_email($email)) {
1050 1050
 			return false;
1051 1051
 		}
1052 1052
 
1053
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1053
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1054 1054
 
1055
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1055
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1056 1056
 
1057
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1057
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1058 1058
 
1059 1059
 		return $ret;
1060 1060
 	}
@@ -1071,16 +1071,16 @@  discard block
 block discarded – undo
1071 1071
 	 *
1072 1072
 	 * @return bool                      If the email was set as primary successfully
1073 1073
 	 */
1074
-	public function set_primary_email( $new_primary_email = '' ) {
1075
-		if ( ! is_email( $new_primary_email ) ) {
1074
+	public function set_primary_email($new_primary_email = '') {
1075
+		if ( ! is_email($new_primary_email)) {
1076 1076
 			return false;
1077 1077
 		}
1078 1078
 
1079
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1079
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1080 1080
 
1081
-		$existing = new Give_Customer( $new_primary_email );
1081
+		$existing = new Give_Customer($new_primary_email);
1082 1082
 
1083
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1083
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1084 1084
 			// This email belongs to another customer
1085 1085
 			return false;
1086 1086
 		}
@@ -1088,21 +1088,21 @@  discard block
 block discarded – undo
1088 1088
 		$old_email = $this->email;
1089 1089
 
1090 1090
 		// Update customer record with new email
1091
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1091
+		$update = $this->update(array('email' => $new_primary_email));
1092 1092
 
1093 1093
 		// Remove new primary from list of additional emails
1094
-		$remove = $this->remove_email( $new_primary_email );
1094
+		$remove = $this->remove_email($new_primary_email);
1095 1095
 
1096 1096
 		// Add old email to additional emails list
1097
-		$add = $this->add_email( $old_email );
1097
+		$add = $this->add_email($old_email);
1098 1098
 
1099 1099
 		$ret = $update && $remove && $add;
1100 1100
 
1101
-		if ( $ret ) {
1101
+		if ($ret) {
1102 1102
 			$this->email = $new_primary_email;
1103 1103
 		}
1104 1104
 
1105
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1105
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1106 1106
 
1107 1107
 		return $ret;
1108 1108
 	}
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		 * @access public
488 488
 		 * @since  1.7
489 489
 		 *
490
-		 * @return bool|void
490
+		 * @return false|null
491 491
 		 */
492 492
 		public function weekly_license_check() {
493 493
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		 * @access public
541 541
 		 * @since  1.7
542 542
 		 *
543
-		 * @return bool|void
543
+		 * @return false|null
544 544
 		 */
545 545
 		public function weekly_subscription_check() {
546 546
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 		 * @access private
622 622
 		 * @since  1.7
623 623
 		 *
624
-		 * @return bool|void
624
+		 * @return false|null
625 625
 		 */
626 626
 		private function __single_subscription_check() {
627 627
 			// Do not fire if license key is not set.
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		 * @access private
834 834
 		 * @since  1.7
835 835
 		 *
836
-		 * @return void|bool
836
+		 * @return false|null
837 837
 		 */
838 838
 		private function __remove_license_key_from_subscriptions() {
839 839
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 		 * @param $plugin_data
933 933
 		 * @param $status
934 934
 		 *
935
-		 * @return bool
935
+		 * @return false|null
936 936
 		 */
937 937
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
938 938
 			// Bailout.
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 		 *
955 955
 		 * @since  1.8.7
956 956
 		 * @access public
957
-		 * @return array
957
+		 * @return string
958 958
 		 */
959 959
 		public function license_state_message() {
960 960
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 		 * @param string $_checkout_url
143 143
 		 * @param string $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 
147 147
 			$give_options = give_get_settings();
148 148
 
149 149
 			$this->file             = $_file;
150 150
 			$this->item_name        = $_item_name;
151
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
151
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
152 152
 			$this->version          = $_version;
153
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
154
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
153
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
154
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
155 155
 			$this->author           = $_author;
156
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
157
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
158
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
156
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
157
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
158
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
159 159
 			$this->auto_updater_obj = null;
160 160
 
161 161
 			// Setup hooks
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 */
177 177
 		private function includes() {
178 178
 
179
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
179
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
180 180
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
181 181
 			}
182 182
 		}
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 		private function hooks() {
195 195
 
196 196
 			// Register settings
197
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
197
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
198 198
 
199 199
 			// Activate license key on settings save
200
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
200
+			add_action('admin_init', array($this, 'activate_license'));
201 201
 
202 202
 			// Deactivate license key
203
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
203
+			add_action('admin_init', array($this, 'deactivate_license'));
204 204
 
205 205
 			// Updater
206
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
207
-			add_action( 'admin_notices', array( $this, 'notices' ) );
206
+			add_action('admin_init', array($this, 'auto_updater'), 0);
207
+			add_action('admin_notices', array($this, 'notices'));
208 208
 
209 209
 			// Check license weekly.
210
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
211
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
210
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
211
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
212 212
 
213 213
 			// Check subscription weekly.
214
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
215
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
214
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
215
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
216 216
 
217 217
 			// Show addon notice on plugin page.
218
-			$plugin_name = explode( 'plugins/', $this->file );
219
-			$plugin_name = end( $plugin_name );
220
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
218
+			$plugin_name = explode('plugins/', $this->file);
219
+			$plugin_name = end($plugin_name);
220
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
221 221
 
222 222
 		}
223 223
 
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @return array           License settings.
259 259
 		 */
260
-		public function settings( $settings ) {
260
+		public function settings($settings) {
261 261
 
262 262
 			$give_license_settings = array(
263 263
 				array(
264 264
 					'name'    => $this->item_name,
265
-					'id'      => $this->item_shortname . '_license_key',
265
+					'id'      => $this->item_shortname.'_license_key',
266 266
 					'desc'    => '',
267 267
 					'type'    => 'license_key',
268 268
 					'options' => array(
269
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
269
+						'license'      => get_option($this->item_shortname.'_license_active'),
270 270
 						'shortname'    => $this->item_shortname,
271 271
 						'item_name'    => $this->item_name,
272 272
 						'api_url'      => $this->api_url,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				),
278 278
 			);
279 279
 
280
-			return array_merge( $settings, $give_license_settings );
280
+			return array_merge($settings, $give_license_settings);
281 281
 		}
282 282
 
283 283
 		/**
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 		 *
293 293
 		 * @return array           License settings content.
294 294
 		 */
295
-		public function license_settings_content( $settings ) {
295
+		public function license_settings_content($settings) {
296 296
 
297 297
 			$give_license_settings = array(
298 298
 				array(
299
-					'name' => __( 'Add-on Licenses', 'give' ),
299
+					'name' => __('Add-on Licenses', 'give'),
300 300
 					'desc' => '<hr>',
301 301
 					'type' => 'give_title',
302 302
 					'id'   => 'give_title',
303 303
 				),
304 304
 			);
305 305
 
306
-			return array_merge( $settings, $give_license_settings );
306
+			return array_merge($settings, $give_license_settings);
307 307
 		}
308 308
 
309 309
 		/**
@@ -318,52 +318,52 @@  discard block
 block discarded – undo
318 318
 		 */
319 319
 		public function activate_license() {
320 320
 			// Bailout: Check if license key set of not.
321
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
321
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
322 322
 				return;
323 323
 			}
324 324
 
325 325
 			// Security check.
326
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
327
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
326
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
327
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
328 328
 			}
329 329
 
330 330
 			// Check if user have correct permissions.
331
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
331
+			if ( ! current_user_can('manage_give_settings')) {
332 332
 				return;
333 333
 			}
334 334
 
335 335
 			// Allow third party addon developers to handle license activation.
336
-			if ( $this->__is_third_party_addon() ) {
337
-				do_action( 'give_activate_license', $this );
336
+			if ($this->__is_third_party_addon()) {
337
+				do_action('give_activate_license', $this);
338 338
 
339 339
 				return;
340 340
 			}
341 341
 
342 342
 			// Delete previous license setting if a empty license key submitted.
343
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
344
-				delete_option( $this->item_shortname . '_license_active' );
343
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
344
+				delete_option($this->item_shortname.'_license_active');
345 345
 
346 346
 				return;
347 347
 			}
348 348
 
349 349
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
350
-			foreach ( $_POST as $key => $value ) {
351
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
350
+			foreach ($_POST as $key => $value) {
351
+				if (false !== strpos($key, 'license_key_deactivate')) {
352 352
 					// Don't activate a key when deactivating a different key
353 353
 					return;
354 354
 				}
355 355
 			}
356 356
 
357 357
 			// Check if plugin previously installed.
358
-			if ( $this->is_valid_license() ) {
358
+			if ($this->is_valid_license()) {
359 359
 				return;
360 360
 			}
361 361
 
362 362
 			// Get license key.
363
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
363
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
364 364
 
365 365
 			// Bailout.
366
-			if ( empty( $license ) ) {
366
+			if (empty($license)) {
367 367
 				return;
368 368
 			}
369 369
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 			$api_params = array(
375 375
 				'edd_action' => 'activate_license', // never change from "edd_" to "give_"!
376 376
 				'license'    => $license,
377
-				'item_name'  => urlencode( $this->item_name ),
377
+				'item_name'  => urlencode($this->item_name),
378 378
 				'url'        => home_url(),
379 379
 			);
380 380
 
@@ -389,19 +389,19 @@  discard block
 block discarded – undo
389 389
 			);
390 390
 
391 391
 			// Make sure there are no errors
392
-			if ( is_wp_error( $response ) ) {
392
+			if (is_wp_error($response)) {
393 393
 				return;
394 394
 			}
395 395
 
396 396
 			// Tell WordPress to look for updates
397
-			set_site_transient( 'update_plugins', null );
397
+			set_site_transient('update_plugins', null);
398 398
 
399 399
 			// Decode license data
400
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
401
-			update_option( $this->item_shortname . '_license_active', $license_data );
400
+			$license_data = json_decode(wp_remote_retrieve_body($response));
401
+			update_option($this->item_shortname.'_license_active', $license_data);
402 402
 
403 403
 			// Add license key.
404
-			give_update_option( "{$this->item_shortname}_license_key", $license );
404
+			give_update_option("{$this->item_shortname}_license_key", $license);
405 405
 
406 406
 			// Check subscription for license key and store this to db (if any).
407 407
 			$this->__single_subscription_check();
@@ -419,33 +419,33 @@  discard block
 block discarded – undo
419 419
 		 */
420 420
 		public function deactivate_license() {
421 421
 
422
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
422
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
423 423
 				return;
424 424
 			}
425 425
 
426
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
427
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
426
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
427
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
428 428
 			}
429 429
 
430
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
430
+			if ( ! current_user_can('manage_give_settings')) {
431 431
 				return;
432 432
 			}
433 433
 
434 434
 			// Allow third party add-on developers to handle license deactivation.
435
-			if ( $this->__is_third_party_addon() ) {
436
-				do_action( 'give_deactivate_license', $this );
435
+			if ($this->__is_third_party_addon()) {
436
+				do_action('give_deactivate_license', $this);
437 437
 
438 438
 				return;
439 439
 			}
440 440
 
441 441
 			// Run on deactivate button press
442
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
442
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
443 443
 
444 444
 				// Data to send to the API
445 445
 				$api_params = array(
446 446
 					'edd_action' => 'deactivate_license', // never change from "edd_" to "give_"!
447 447
 					'license'    => $this->license,
448
-					'item_name'  => urlencode( $this->item_name ),
448
+					'item_name'  => urlencode($this->item_name),
449 449
 					'url'        => home_url(),
450 450
 				);
451 451
 
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
 				);
461 461
 
462 462
 				// Make sure there are no errors
463
-				if ( is_wp_error( $response ) ) {
463
+				if (is_wp_error($response)) {
464 464
 					return;
465 465
 				}
466 466
 
467 467
 				// Decode the license data
468
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
468
+				$license_data = json_decode(wp_remote_retrieve_body($response));
469 469
 
470 470
 				// Ensure deactivated successfully.
471
-				if ( isset( $license_data->success ) ) {
471
+				if (isset($license_data->success)) {
472 472
 
473 473
 					// Remove license data.
474
-					delete_option( $this->item_shortname . '_license_active' );
474
+					delete_option($this->item_shortname.'_license_active');
475 475
 					
476
-					give_delete_option( $this->item_shortname . '_license_key' );
476
+					give_delete_option($this->item_shortname.'_license_key');
477 477
 
478 478
 					// Remove license key from subscriptions if exist.
479 479
 					$this->__remove_license_key_from_subscriptions();
@@ -492,18 +492,18 @@  discard block
 block discarded – undo
492 492
 		 */
493 493
 		public function weekly_license_check() {
494 494
 
495
-			if ( ! empty( $_POST['give_settings'] ) ) {
495
+			if ( ! empty($_POST['give_settings'])) {
496 496
 				// Don't fire when saving settings
497 497
 				return false;
498 498
 			}
499 499
 
500
-			if ( empty( $this->license ) ) {
500
+			if (empty($this->license)) {
501 501
 				return false;
502 502
 			}
503 503
 
504 504
 			// Allow third party add-on developers to handle their license check.
505
-			if ( $this->__is_third_party_addon() ) {
506
-				do_action( 'give_weekly_license_check', $this );
505
+			if ($this->__is_third_party_addon()) {
506
+				do_action('give_weekly_license_check', $this);
507 507
 
508 508
 				return false;
509 509
 			}
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$api_params = array(
513 513
 				'edd_action' => 'check_license',
514 514
 				'license'    => $this->license,
515
-				'item_name'  => urlencode( $this->item_name ),
515
+				'item_name'  => urlencode($this->item_name),
516 516
 				'url'        => home_url(),
517 517
 			);
518 518
 
@@ -527,12 +527,12 @@  discard block
 block discarded – undo
527 527
 			);
528 528
 
529 529
 			// Make sure the response came back okay.
530
-			if ( is_wp_error( $response ) ) {
530
+			if (is_wp_error($response)) {
531 531
 				return false;
532 532
 			}
533 533
 
534
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
535
-			update_option( $this->item_shortname . '_license_active', $license_data );
534
+			$license_data = json_decode(wp_remote_retrieve_body($response));
535
+			update_option($this->item_shortname.'_license_active', $license_data);
536 536
 		}
537 537
 
538 538
 		/**
@@ -545,24 +545,24 @@  discard block
 block discarded – undo
545 545
 		 */
546 546
 		public function weekly_subscription_check() {
547 547
 
548
-			if ( ! empty( $_POST['give_settings'] ) ) {
548
+			if ( ! empty($_POST['give_settings'])) {
549 549
 				// Don't fire when saving settings
550 550
 				return false;
551 551
 			}
552 552
 
553 553
 			// Remove old subscription data.
554
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
555
-				delete_option( 'give_subscriptions' );
556
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
554
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
555
+				delete_option('give_subscriptions');
556
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
557 557
 			}
558 558
 
559
-			if ( empty( $this->license ) ) {
559
+			if (empty($this->license)) {
560 560
 				return false;
561 561
 			}
562 562
 
563 563
 			// Allow third party add-on developers to handle their subscription check.
564
-			if ( $this->__is_third_party_addon() ) {
565
-				do_action( 'give_weekly_subscription_check', $this );
564
+			if ($this->__is_third_party_addon()) {
565
+				do_action('give_weekly_subscription_check', $this);
566 566
 
567 567
 				return false;
568 568
 			}
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 				// This is a custom feature to check subscriptions.
578 578
 				'edd_action' => 'check_subscription',
579 579
 				'license'    => $this->license,
580
-				'item_name'  => urlencode( $this->item_name ),
580
+				'item_name'  => urlencode($this->item_name),
581 581
 				'url'        => home_url(),
582 582
 			);
583 583
 
@@ -592,27 +592,27 @@  discard block
 block discarded – undo
592 592
 			);
593 593
 
594 594
 			// Make sure the response came back okay.
595
-			if ( is_wp_error( $response ) ) {
595
+			if (is_wp_error($response)) {
596 596
 				return false;
597 597
 			}
598 598
 
599
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
599
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
600 600
 
601
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
602
-				$subscriptions = get_option( 'give_subscriptions', array() );
601
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
602
+				$subscriptions = get_option('give_subscriptions', array());
603 603
 
604 604
 				// Update subscription data only if subscription does not exist already.
605
-				if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
606
-					$subscriptions[ $subscription_data['id'] ]             = $subscription_data;
607
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
605
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
606
+					$subscriptions[$subscription_data['id']]             = $subscription_data;
607
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
608 608
 				}
609 609
 
610 610
 				// Store licenses for subscription.
611
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
612
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
611
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
612
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
613 613
 				}
614 614
 
615
-				update_option( 'give_subscriptions', $subscriptions );
615
+				update_option('give_subscriptions', $subscriptions);
616 616
 			}
617 617
 		}
618 618
 
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 		 */
627 627
 		private function __single_subscription_check() {
628 628
 			// Do not fire if license key is not set.
629
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
629
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
630 630
 				return false;
631 631
 			}
632 632
 
633
-			if ( empty( $this->license ) ) {
633
+			if (empty($this->license)) {
634 634
 				return false;
635 635
 			}
636 636
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 				// This is a custom feature to check subscriptions.
642 642
 				'edd_action' => 'check_subscription',
643 643
 				'license'    => $this->license,
644
-				'item_name'  => urlencode( $this->item_name ),
644
+				'item_name'  => urlencode($this->item_name),
645 645
 				'url'        => home_url(),
646 646
 			);
647 647
 
@@ -656,27 +656,27 @@  discard block
 block discarded – undo
656 656
 			);
657 657
 
658 658
 			// Make sure the response came back okay.
659
-			if ( is_wp_error( $response ) ) {
659
+			if (is_wp_error($response)) {
660 660
 				return false;
661 661
 			}
662 662
 
663
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
663
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
664 664
 
665
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
666
-				$subscriptions = get_option( 'give_subscriptions', array() );
665
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
666
+				$subscriptions = get_option('give_subscriptions', array());
667 667
 
668 668
 				// Update subscription data only if subscription does not exist already.
669
-				if ( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
670
-					$subscriptions[ $subscription_data['id'] ]             = $subscription_data;
671
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
669
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
670
+					$subscriptions[$subscription_data['id']]             = $subscription_data;
671
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
672 672
 				}
673 673
 
674 674
 				// Store licenses for subscription.
675
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
676
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
675
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
676
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
677 677
 				}
678 678
 
679
-				update_option( 'give_subscriptions', $subscriptions );
679
+				update_option('give_subscriptions', $subscriptions);
680 680
 			}
681 681
 		}
682 682
 
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
 		 */
691 691
 		public function notices() {
692 692
 
693
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
693
+			if ( ! current_user_can('manage_give_settings')) {
694 694
 				return;
695 695
 			}
696 696
 
697 697
 			// Do not show licenses notices on license tab.
698
-			if ( 'licenses' === give_get_current_setting_tab() ) {
698
+			if ('licenses' === give_get_current_setting_tab()) {
699 699
 				return;
700 700
 			}
701 701
 
@@ -704,93 +704,93 @@  discard block
 block discarded – undo
704 704
 			static $addon_license_key_in_subscriptions;
705 705
 
706 706
 			// Set default value.
707
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
707
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
708 708
 			$messages                           = array();
709 709
 
710 710
 			if (
711
-				empty( $this->license )
712
-				&& ! $this->__is_notice_dismissed( 'general' )
713
-				&& empty( $showed_invalid_message )
711
+				empty($this->license)
712
+				&& ! $this->__is_notice_dismissed('general')
713
+				&& empty($showed_invalid_message)
714 714
 			) {
715
-				$messages['general']    = sprintf(
716
-					__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
717
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
715
+				$messages['general'] = sprintf(
716
+					__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
717
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
718 718
 				);
719 719
 				$showed_invalid_message = true;
720 720
 
721 721
 			}
722 722
 
723 723
 			// Get subscriptions.
724
-			$subscriptions = get_option( 'give_subscriptions' );
724
+			$subscriptions = get_option('give_subscriptions');
725 725
 
726 726
 			// Show subscription messages.
727
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
727
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
728 728
 
729
-				foreach ( $subscriptions as $subscription ) {
729
+				foreach ($subscriptions as $subscription) {
730 730
 					// Subscription expires timestamp.
731
-					$subscription_expires = strtotime( $subscription['expires'] );
731
+					$subscription_expires = strtotime($subscription['expires']);
732 732
 
733 733
 					// Start showing subscriptions message before one week of renewal date.
734
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
734
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
735 735
 						continue;
736 736
 					}
737 737
 
738 738
 					// Check if subscription message already exist in messages.
739
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
739
+					if (array_key_exists($subscription['id'], $messages)) {
740 740
 						continue;
741 741
 					}
742 742
 
743
-					if ( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) {
743
+					if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) {
744 744
 
745
-						if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired.
746
-							$messages[ $subscription['id'] ] = sprintf(
747
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give' ),
748
-								urldecode( $subscription['invoice_url'] ),
745
+						if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired.
746
+							$messages[$subscription['id']] = sprintf(
747
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or <a href="%4$s">Click here if already renewed</a>.', 'give'),
748
+								urldecode($subscription['invoice_url']),
749 749
 								$subscription['payment_id'],
750 750
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
751
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
751
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
752 752
 							);
753 753
 						} else {
754
-							$messages[ $subscription['id'] ] = sprintf(
755
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give' ),
756
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
757
-								urldecode( $subscription['invoice_url'] ),
754
+							$messages[$subscription['id']] = sprintf(
755
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or <a href="%5$s">Click here if already renewed</a>.', 'give'),
756
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
757
+								urldecode($subscription['invoice_url']),
758 758
 								$subscription['payment_id'],
759 759
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
760
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
760
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
761 761
 							);
762 762
 						}
763 763
 					}
764 764
 
765 765
 					// Stop validation for these license keys.
766
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
766
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
767 767
 				}// End foreach().
768 768
 				$showed_subscriptions_message = true;
769 769
 			}// End if().
770 770
 
771 771
 			// Show non subscription addon messages.
772 772
 			if (
773
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
774
-				&& ! $this->__is_notice_dismissed( 'general' )
773
+				! in_array($this->license, $addon_license_key_in_subscriptions)
774
+				&& ! $this->__is_notice_dismissed('general')
775 775
 				&& ! $this->is_valid_license()
776
-				&& empty( $showed_invalid_message )
776
+				&& empty($showed_invalid_message)
777 777
 			) {
778 778
 
779
-				$messages['general']    = sprintf(
780
-					__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
781
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
779
+				$messages['general'] = sprintf(
780
+					__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
781
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
782 782
 				);
783 783
 				$showed_invalid_message = true;
784 784
 
785 785
 			}
786 786
 
787 787
 			// Print messages.
788
-			if ( ! empty( $messages ) ) {
789
-				foreach ( $messages as $notice_id => $message ) {
788
+			if ( ! empty($messages)) {
789
+				foreach ($messages as $notice_id => $message) {
790 790
 
791 791
 					echo sprintf(
792 792
 						'<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>',
793
-						esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ),
793
+						esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])),
794 794
 						$message
795 795
 					);
796 796
 				}
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		 * @return bool
807 807
 		 */
808 808
 		public function is_valid_license() {
809
-			if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) {
809
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
810 810
 				return true;
811 811
 			}
812 812
 
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		 * @return bool
823 823
 		 */
824 824
 		private function __is_third_party_addon() {
825
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
825
+			return (false === strpos($this->api_url, 'givewp.com/'));
826 826
 		}
827 827
 
828 828
 		/**
@@ -837,25 +837,25 @@  discard block
 block discarded – undo
837 837
 		 * @return void|bool
838 838
 		 */
839 839
 		private function __remove_license_key_from_subscriptions() {
840
-			$subscriptions = get_option( 'give_subscriptions', array() );
840
+			$subscriptions = get_option('give_subscriptions', array());
841 841
 
842 842
 			// Bailout.
843
-			if ( empty( $this->license ) ) {
843
+			if (empty($this->license)) {
844 844
 				return false;
845 845
 			}
846 846
 
847
-			if ( ! empty( $subscriptions ) ) {
848
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
849
-					$license_index = array_search( $this->license, $subscription['licenses'] );
850
-					if ( false !== $license_index ) {
847
+			if ( ! empty($subscriptions)) {
848
+				foreach ($subscriptions as $subscription_id => $subscription) {
849
+					$license_index = array_search($this->license, $subscription['licenses']);
850
+					if (false !== $license_index) {
851 851
 						// Remove license key.
852
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
852
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
853 853
 
854 854
 						// Rearrange license keys.
855
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
855
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
856 856
 
857 857
 						// Update subscription information.
858
-						update_option( 'give_subscriptions', $subscriptions );
858
+						update_option('give_subscriptions', $subscriptions);
859 859
 						break;
860 860
 					}
861 861
 				}
@@ -908,18 +908,18 @@  discard block
 block discarded – undo
908 908
 		 *
909 909
 		 * @return bool
910 910
 		 */
911
-		private function __is_notice_dismissed( $notice_id ) {
911
+		private function __is_notice_dismissed($notice_id) {
912 912
 			$current_user        = wp_get_current_user();
913 913
 			$is_notice_dismissed = false;
914 914
 
915 915
 			// Ge is notice dismissed permanently.
916
-			$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
916
+			$already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
917 917
 				? $already_dismiss_notices
918 918
 				: array();
919 919
 
920 920
 			if (
921
-				in_array( $notice_id, $already_dismiss_notices )
922
-				|| false !== Give_Cache::get( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true )
921
+				in_array($notice_id, $already_dismiss_notices)
922
+				|| false !== Give_Cache::get("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}", true)
923 923
 			) {
924 924
 				$is_notice_dismissed = true;
925 925
 			}
@@ -935,17 +935,17 @@  discard block
 block discarded – undo
935 935
 		 *
936 936
 		 * @return bool
937 937
 		 */
938
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
938
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
939 939
 			// Bailout.
940
-			if ( $this->is_valid_license() ) {
940
+			if ($this->is_valid_license()) {
941 941
 				return false;
942 942
 			}
943 943
 
944 944
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
945 945
 			$message            = $this->license_state_message();
946 946
 
947
-			if ( ! empty( $message['message'] ) ) {
948
-				echo sprintf( $update_notice_wrap, $message['message'] );
947
+			if ( ! empty($message['message'])) {
948
+				echo sprintf($update_notice_wrap, $message['message']);
949 949
 			}
950 950
 		}
951 951
 
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 		public function license_state_message() {
961 961
 			$message_data = array();
962 962
 
963
-			if ( ! $this->is_valid_license() ) {
963
+			if ( ! $this->is_valid_license()) {
964 964
 
965 965
 				$message_data['message'] = sprintf(
966 966
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
967
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
967
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
968 968
 					$this->item_name
969 969
 				);
970 970
 			}
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
  *
368 368
  * @since  1.0
369 369
  *
370
- * @param  int|bool $form_id Form ID (default: false).
370
+ * @param  boolean $form_id Form ID (default: false).
371 371
  * @param  int $payment_id Payment ID.
372 372
  *
373 373
  * @return void
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
  * @param  int $year Year number. Default is null.
692 692
  * @param  int $hour Hour number. Default is null.
693 693
  *
694
- * @return int $earnings  Earnings
694
+ * @return double $earnings  Earnings
695 695
  */
696 696
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
697 697
 
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
  *
998 998
  * @param int $payment_id Payment ID.
999 999
  *
1000
- * @return int $form_id Form ID.
1000
+ * @return string $form_id Form ID.
1001 1001
  */
1002 1002
 function give_get_payment_form_id( $payment_id ) {
1003 1003
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
169 169
 		'price'    => $payment->total,
170 170
 		'price_id' => $payment->price_id,
171
-		'fees'     => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(),
171
+		'fees'     => isset($payment_data['fees']) ? $payment_data['fees'] : array(),
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 	// Set date if present.
177
-	if ( isset( $payment_data['post_date'] ) ) {
177
+	if (isset($payment_data['post_date'])) {
178 178
 		$payment->date = $payment_data['post_date'];
179 179
 	}
180 180
 
181 181
 	// Handle sequential payments.
182
-	if ( give_get_option( 'enable_sequential' ) ) {
182
+	if (give_get_option('enable_sequential')) {
183 183
 		$number          = give_get_next_payment_number();
184
-		$payment->number = give_format_payment_number( $number );
185
-		update_option( 'give_last_payment_number', $number );
184
+		$payment->number = give_format_payment_number($number);
185
+		update_option('give_last_payment_number', $number);
186 186
 	}
187 187
 
188 188
 	// Clear the user's donation cache.
189
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
189
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
190 190
 
191 191
 	// Save payment.
192 192
 	$payment->save();
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @param int $payment_id The payment ID.
200 200
 	 * @param array $payment_data Arguments passed.
201 201
 	 */
202
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
202
+	do_action('give_insert_payment', $payment->ID, $payment_data);
203 203
 
204 204
 	// Return payment ID upon success.
205
-	if ( ! empty( $payment->ID ) ) {
205
+	if ( ! empty($payment->ID)) {
206 206
 		return $payment->ID;
207 207
 	}
208 208
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return bool|int
220 220
  */
221
-function give_create_payment( $payment_data ) {
221
+function give_create_payment($payment_data) {
222 222
 
223
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
224
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
223
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
224
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
225 225
 
226 226
 	// Collect payment data.
227 227
 	$insert_payment_data = array(
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @param array $insert_payment_data
247 247
 	 */
248
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
248
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
249 249
 
250 250
 	// Record the pending payment.
251
-	return give_insert_payment( $insert_payment_data );
251
+	return give_insert_payment($insert_payment_data);
252 252
 }
253 253
 
254 254
 /**
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @return bool
263 263
  */
264
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
264
+function give_update_payment_status($payment_id, $new_status = 'publish') {
265 265
 
266
-	$payment         = new Give_Payment( $payment_id );
266
+	$payment         = new Give_Payment($payment_id);
267 267
 	$payment->status = $new_status;
268 268
 	$updated         = $payment->save();
269 269
 
@@ -282,38 +282,38 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @return void
284 284
  */
285
-function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
285
+function give_delete_purchase($payment_id = 0, $update_customer = true) {
286 286
 	global $give_logs;
287 287
 
288
-	$payment     = new Give_Payment( $payment_id );
289
-	$amount      = give_get_payment_amount( $payment_id );
288
+	$payment     = new Give_Payment($payment_id);
289
+	$amount      = give_get_payment_amount($payment_id);
290 290
 	$status      = $payment->post_status;
291
-	$customer_id = give_get_payment_customer_id( $payment_id );
292
-	$customer    = new Give_Customer( $customer_id );
291
+	$customer_id = give_get_payment_customer_id($payment_id);
292
+	$customer    = new Give_Customer($customer_id);
293 293
 
294 294
 	// Only undo donations that aren't these statuses.
295
-	$dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array(
295
+	$dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array(
296 296
 		'pending',
297 297
 		'cancelled',
298
-	) );
298
+	));
299 299
 
300
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
301
-		give_undo_purchase( false, $payment_id );
300
+	if ( ! in_array($status, $dont_undo_statuses)) {
301
+		give_undo_purchase(false, $payment_id);
302 302
 	}
303 303
 
304
-	if ( $status == 'publish' ) {
304
+	if ($status == 'publish') {
305 305
 
306 306
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
307
-		give_decrease_total_earnings( $amount );
307
+		give_decrease_total_earnings($amount);
308 308
 
309 309
 		// @todo: Refresh only range related stat cache
310 310
 		give_delete_donation_stats();
311 311
 
312
-		if ( $customer->id && $update_customer ) {
312
+		if ($customer->id && $update_customer) {
313 313
 
314 314
 			// Decrement the stats for the donor.
315 315
 			$customer->decrease_purchase_count();
316
-			$customer->decrease_value( $amount );
316
+			$customer->decrease_value($amount);
317 317
 
318 318
 		}
319 319
 	}
@@ -325,17 +325,17 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @param int $payment_id Payment ID.
327 327
 	 */
328
-	do_action( 'give_payment_delete', $payment_id );
328
+	do_action('give_payment_delete', $payment_id);
329 329
 
330
-	if ( $customer->id && $update_customer ) {
330
+	if ($customer->id && $update_customer) {
331 331
 
332 332
 		// Remove the payment ID from the donor.
333
-		$customer->remove_payment( $payment_id );
333
+		$customer->remove_payment($payment_id);
334 334
 
335 335
 	}
336 336
 
337 337
 	// Remove the payment.
338
-	wp_delete_post( $payment_id, true );
338
+	wp_delete_post($payment_id, true);
339 339
 
340 340
 	// Remove related sale log entries.
341 341
 	$give_logs->delete_logs(
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @param int $payment_id Payment ID.
358 358
 	 */
359
-	do_action( 'give_payment_deleted', $payment_id );
359
+	do_action('give_payment_deleted', $payment_id);
360 360
 }
361 361
 
362 362
 /**
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return void
374 374
  */
375
-function give_undo_purchase( $form_id = false, $payment_id ) {
375
+function give_undo_purchase($form_id = false, $payment_id) {
376 376
 
377
-	if ( ! empty( $form_id ) ) {
377
+	if ( ! empty($form_id)) {
378 378
 		$form_id = false;
379
-		_give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' );
379
+		_give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
380 380
 	}
381 381
 
382
-	$payment = new Give_Payment( $payment_id );
382
+	$payment = new Give_Payment($payment_id);
383 383
 
384
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
385
-	if ( true === $maybe_decrease_earnings ) {
384
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
385
+	if (true === $maybe_decrease_earnings) {
386 386
 		// Decrease earnings.
387
-		give_decrease_earnings( $payment->form_id, $payment->total );
387
+		give_decrease_earnings($payment->form_id, $payment->total);
388 388
 	}
389 389
 
390
-	$maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id );
391
-	if ( true === $maybe_decrease_sales ) {
390
+	$maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id);
391
+	if (true === $maybe_decrease_sales) {
392 392
 		// Decrease donation count.
393
-		give_decrease_purchase_count( $payment->form_id );
393
+		give_decrease_purchase_count($payment->form_id);
394 394
 	}
395 395
 
396 396
 }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
  *
408 408
  * @return object $stats Contains the number of payments per payment status.
409 409
  */
410
-function give_count_payments( $args = array() ) {
410
+function give_count_payments($args = array()) {
411 411
 
412 412
 	global $wpdb;
413 413
 
@@ -419,18 +419,18 @@  discard block
 block discarded – undo
419 419
 		'form_id'    => null,
420 420
 	);
421 421
 
422
-	$args = wp_parse_args( $args, $defaults );
422
+	$args = wp_parse_args($args, $defaults);
423 423
 
424 424
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
425 425
 	$join   = '';
426 426
 	$where  = "WHERE p.post_type = 'give_payment'";
427 427
 
428 428
 	// Count payments for a specific user.
429
-	if ( ! empty( $args['user'] ) ) {
429
+	if ( ! empty($args['user'])) {
430 430
 
431
-		if ( is_email( $args['user'] ) ) {
431
+		if (is_email($args['user'])) {
432 432
 			$field = 'email';
433
-		} elseif ( is_numeric( $args['user'] ) ) {
433
+		} elseif (is_numeric($args['user'])) {
434 434
 			$field = 'id';
435 435
 		} else {
436 436
 			$field = '';
@@ -438,105 +438,105 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
440 440
 
441
-		if ( ! empty( $field ) ) {
441
+		if ( ! empty($field)) {
442 442
 			$where .= "
443 443
 				AND m.meta_key = '_give_payment_user_{$field}'
444 444
 				AND m.meta_value = '{$args['user']}'";
445 445
 		}
446 446
 
447 447
 		// Count payments for a search.
448
-	} elseif ( ! empty( $args['s'] ) ) {
448
+	} elseif ( ! empty($args['s'])) {
449 449
 
450
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
450
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
451 451
 
452
-			if ( is_email( $args['s'] ) ) {
452
+			if (is_email($args['s'])) {
453 453
 				$field = '_give_payment_user_email';
454 454
 			} else {
455 455
 				$field = '_give_payment_purchase_key';
456 456
 			}
457 457
 
458
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
-			$where .= $wpdb->prepare( '
458
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
+			$where .= $wpdb->prepare('
460 460
                 AND m.meta_key = %s
461 461
                 AND m.meta_value = %s',
462 462
 				$field,
463 463
 				$args['s']
464 464
 			);
465 465
 
466
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
466
+		} elseif ('#' == substr($args['s'], 0, 1)) {
467 467
 
468
-			$search = str_replace( '#:', '', $args['s'] );
469
-			$search = str_replace( '#', '', $search );
468
+			$search = str_replace('#:', '', $args['s']);
469
+			$search = str_replace('#', '', $search);
470 470
 
471 471
 			$select = 'SELECT p2.post_status,count( * ) AS num_posts ';
472 472
 			$join   = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID ";
473 473
 			$join   .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID ";
474 474
 			$where  = "WHERE p.post_type = 'give_log' ";
475
-			$where  .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search );
475
+			$where  .= $wpdb->prepare('AND p.post_parent = %d} ', $search);
476 476
 
477
-		} elseif ( is_numeric( $args['s'] ) ) {
477
+		} elseif (is_numeric($args['s'])) {
478 478
 
479
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
480
-			$where .= $wpdb->prepare( "
479
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
480
+			$where .= $wpdb->prepare("
481 481
 				AND m.meta_key = '_give_payment_user_id'
482 482
 				AND m.meta_value = %d",
483 483
 				$args['s']
484 484
 			);
485 485
 
486 486
 		} else {
487
-			$search = $wpdb->esc_like( $args['s'] );
488
-			$search = '%' . $search . '%';
487
+			$search = $wpdb->esc_like($args['s']);
488
+			$search = '%'.$search.'%';
489 489
 
490
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
490
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
491 491
 		}
492 492
 	}
493 493
 
494
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
494
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
495 495
 
496
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
496
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
497 497
 
498 498
 	}
499 499
 	// Limit payments count by date.
500
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
500
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
501 501
 
502
-		$date_parts = explode( '/', $args['start-date'] );
503
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
504
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
505
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
502
+		$date_parts = explode('/', $args['start-date']);
503
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
504
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
505
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
506 506
 
507
-		$is_date = checkdate( $month, $day, $year );
508
-		if ( false !== $is_date ) {
507
+		$is_date = checkdate($month, $day, $year);
508
+		if (false !== $is_date) {
509 509
 
510
-			$date  = new DateTime( $args['start-date'] );
511
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
510
+			$date = new DateTime($args['start-date']);
511
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
512 512
 
513 513
 		}
514 514
 
515 515
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class).
516
-		if ( empty( $args['end-date'] ) ) {
516
+		if (empty($args['end-date'])) {
517 517
 			$args['end-date'] = $args['start-date'];
518 518
 		}
519 519
 	}
520 520
 
521
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
521
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
522 522
 
523
-		$date_parts = explode( '/', $args['end-date'] );
523
+		$date_parts = explode('/', $args['end-date']);
524 524
 
525
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
526
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
527
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
525
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
526
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
527
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
528 528
 
529
-		$is_date = checkdate( $month, $day, $year );
530
-		if ( false !== $is_date ) {
529
+		$is_date = checkdate($month, $day, $year);
530
+		if (false !== $is_date) {
531 531
 
532
-			$date  = new DateTime( $args['end-date'] );
533
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
532
+			$date = new DateTime($args['end-date']);
533
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
534 534
 
535 535
 		}
536 536
 	}
537 537
 
538
-	$where = apply_filters( 'give_count_payments_where', $where );
539
-	$join  = apply_filters( 'give_count_payments_join', $join );
538
+	$where = apply_filters('give_count_payments_where', $where);
539
+	$join  = apply_filters('give_count_payments_join', $join);
540 540
 
541 541
 	$query = "$select
542 542
 		FROM $wpdb->posts p
@@ -545,36 +545,36 @@  discard block
 block discarded – undo
545 545
 		GROUP BY p.post_status
546 546
 	";
547 547
 
548
-	$cache_key = md5( $query );
548
+	$cache_key = md5($query);
549 549
 
550
-	$count = wp_cache_get( $cache_key, 'counts' );
551
-	if ( false !== $count ) {
550
+	$count = wp_cache_get($cache_key, 'counts');
551
+	if (false !== $count) {
552 552
 		return $count;
553 553
 	}
554 554
 
555
-	$count = $wpdb->get_results( $query, ARRAY_A );
555
+	$count = $wpdb->get_results($query, ARRAY_A);
556 556
 
557 557
 	$stats    = array();
558 558
 	$statuses = get_post_stati();
559
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
560
-		unset( $statuses['private'] );
559
+	if (isset($statuses['private']) && empty($args['s'])) {
560
+		unset($statuses['private']);
561 561
 	}
562 562
 
563
-	foreach ( $statuses as $state ) {
564
-		$stats[ $state ] = 0;
563
+	foreach ($statuses as $state) {
564
+		$stats[$state] = 0;
565 565
 	}
566 566
 
567
-	foreach ( (array) $count as $row ) {
567
+	foreach ((array) $count as $row) {
568 568
 
569
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
569
+		if ('private' == $row['post_status'] && empty($args['s'])) {
570 570
 			continue;
571 571
 		}
572 572
 
573
-		$stats[ $row['post_status'] ] = $row['num_posts'];
573
+		$stats[$row['post_status']] = $row['num_posts'];
574 574
 	}
575 575
 
576 576
 	$stats = (object) $stats;
577
-	wp_cache_set( $cache_key, $stats, 'counts' );
577
+	wp_cache_set($cache_key, $stats, 'counts');
578 578
 
579 579
 	return $stats;
580 580
 }
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
  *
590 590
  * @return bool $exists True if payment exists, false otherwise.
591 591
  */
592
-function give_check_for_existing_payment( $payment_id ) {
592
+function give_check_for_existing_payment($payment_id) {
593 593
 	$exists  = false;
594
-	$payment = new Give_Payment( $payment_id );
594
+	$payment = new Give_Payment($payment_id);
595 595
 
596
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
596
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
597 597
 		$exists = true;
598 598
 	}
599 599
 
@@ -611,31 +611,31 @@  discard block
 block discarded – undo
611 611
  *
612 612
  * @return bool|mixed True if payment status exists, false otherwise.
613 613
  */
614
-function give_get_payment_status( $payment, $return_label = false ) {
614
+function give_get_payment_status($payment, $return_label = false) {
615 615
 
616
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
616
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
617 617
 		return false;
618 618
 	}
619 619
 
620 620
 	$statuses = give_get_payment_statuses();
621 621
 
622
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
622
+	if ( ! is_array($statuses) || empty($statuses)) {
623 623
 		return false;
624 624
 	}
625 625
 
626 626
 	// Get payment object if no already given.
627
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
627
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
628 628
 
629
-	if ( array_key_exists( $payment->status, $statuses ) ) {
630
-		if ( true === $return_label ) {
629
+	if (array_key_exists($payment->status, $statuses)) {
630
+		if (true === $return_label) {
631 631
 			// Return translated status label.
632
-			return $statuses[ $payment->status ];
632
+			return $statuses[$payment->status];
633 633
 		} else {
634 634
 			// Account that our 'publish' status is labeled 'Complete'
635 635
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
636 636
 
637 637
 			// Make sure we're matching cases, since they matter
638
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
638
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
639 639
 		}
640 640
 	}
641 641
 
@@ -651,18 +651,18 @@  discard block
 block discarded – undo
651 651
  */
652 652
 function give_get_payment_statuses() {
653 653
 	$payment_statuses = array(
654
-		'pending'     => __( 'Pending', 'give' ),
655
-		'publish'     => __( 'Complete', 'give' ),
656
-		'refunded'    => __( 'Refunded', 'give' ),
657
-		'failed'      => __( 'Failed', 'give' ),
658
-		'cancelled'   => __( 'Cancelled', 'give' ),
659
-		'abandoned'   => __( 'Abandoned', 'give' ),
660
-		'preapproval' => __( 'Pre-Approved', 'give' ),
661
-		'processing'  => __( 'Processing', 'give' ),
662
-		'revoked'     => __( 'Revoked', 'give' ),
654
+		'pending'     => __('Pending', 'give'),
655
+		'publish'     => __('Complete', 'give'),
656
+		'refunded'    => __('Refunded', 'give'),
657
+		'failed'      => __('Failed', 'give'),
658
+		'cancelled'   => __('Cancelled', 'give'),
659
+		'abandoned'   => __('Abandoned', 'give'),
660
+		'preapproval' => __('Pre-Approved', 'give'),
661
+		'processing'  => __('Processing', 'give'),
662
+		'revoked'     => __('Revoked', 'give'),
663 663
 	);
664 664
 
665
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
665
+	return apply_filters('give_payment_statuses', $payment_statuses);
666 666
 }
667 667
 
668 668
 /**
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
  * @return array $payment_status All the available payment statuses.
676 676
  */
677 677
 function give_get_payment_status_keys() {
678
-	$statuses = array_keys( give_get_payment_statuses() );
679
-	asort( $statuses );
678
+	$statuses = array_keys(give_get_payment_statuses());
679
+	asort($statuses);
680 680
 
681
-	return array_values( $statuses );
681
+	return array_values($statuses);
682 682
 }
683 683
 
684 684
 /**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  *
694 694
  * @return int $earnings  Earnings
695 695
  */
696
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
696
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
697 697
 
698 698
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
699 699
 	global $wpdb;
@@ -703,41 +703,41 @@  discard block
 block discarded – undo
703 703
 		'nopaging'               => true,
704 704
 		'year'                   => $year,
705 705
 		'monthnum'               => $month_num,
706
-		'post_status'            => array( 'publish' ),
706
+		'post_status'            => array('publish'),
707 707
 		'fields'                 => 'ids',
708 708
 		'update_post_term_cache' => false,
709 709
 	);
710
-	if ( ! empty( $day ) ) {
710
+	if ( ! empty($day)) {
711 711
 		$args['day'] = $day;
712 712
 	}
713 713
 
714
-	if ( ! empty( $hour ) ) {
714
+	if ( ! empty($hour)) {
715 715
 		$args['hour'] = $hour;
716 716
 	}
717 717
 
718
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
719
-	$key  = Give_Cache::get_key( 'give_stats', $args );
718
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
719
+	$key  = Give_Cache::get_key('give_stats', $args);
720 720
 
721
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
721
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
722 722
 		$earnings = false;
723 723
 	} else {
724
-		$earnings = Give_Cache::get( $key );
724
+		$earnings = Give_Cache::get($key);
725 725
 	}
726 726
 
727
-	if ( false === $earnings ) {
728
-		$sales    = get_posts( $args );
727
+	if (false === $earnings) {
728
+		$sales    = get_posts($args);
729 729
 		$earnings = 0;
730
-		if ( $sales ) {
731
-			$sales = implode( ',', $sales );
730
+		if ($sales) {
731
+			$sales = implode(',', $sales);
732 732
 
733
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" );
733
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})");
734 734
 
735 735
 		}
736 736
 		// Cache the results for one hour.
737
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
737
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
738 738
 	}
739 739
 
740
-	return round( $earnings, 2 );
740
+	return round($earnings, 2);
741 741
 }
742 742
 
743 743
 /**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  *
753 753
  * @return int $count     Sales
754 754
  */
755
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
755
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
756 756
 
757 757
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
758 758
 	$args = array(
@@ -760,14 +760,14 @@  discard block
 block discarded – undo
760 760
 		'nopaging'               => true,
761 761
 		'year'                   => $year,
762 762
 		'fields'                 => 'ids',
763
-		'post_status'            => array( 'publish' ),
763
+		'post_status'            => array('publish'),
764 764
 		'update_post_meta_cache' => false,
765 765
 		'update_post_term_cache' => false,
766 766
 	);
767 767
 
768
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
768
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
769 769
 
770
-	if ( false === $show_free ) {
770
+	if (false === $show_free) {
771 771
 		$args['meta_query'] = array(
772 772
 			array(
773 773
 				'key'     => '_give_payment_total',
@@ -778,33 +778,33 @@  discard block
 block discarded – undo
778 778
 		);
779 779
 	}
780 780
 
781
-	if ( ! empty( $month_num ) ) {
781
+	if ( ! empty($month_num)) {
782 782
 		$args['monthnum'] = $month_num;
783 783
 	}
784 784
 
785
-	if ( ! empty( $day ) ) {
785
+	if ( ! empty($day)) {
786 786
 		$args['day'] = $day;
787 787
 	}
788 788
 
789
-	if ( ! empty( $hour ) ) {
789
+	if ( ! empty($hour)) {
790 790
 		$args['hour'] = $hour;
791 791
 	}
792 792
 
793
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
793
+	$args = apply_filters('give_get_sales_by_date_args', $args);
794 794
 
795
-	$key = Give_Cache::get_key( 'give_stats', $args );
795
+	$key = Give_Cache::get_key('give_stats', $args);
796 796
 
797
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
797
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
798 798
 		$count = false;
799 799
 	} else {
800
-		$count = Give_Cache::get( $key );
800
+		$count = Give_Cache::get($key);
801 801
 	}
802 802
 
803
-	if ( false === $count ) {
804
-		$sales = new WP_Query( $args );
803
+	if (false === $count) {
804
+		$sales = new WP_Query($args);
805 805
 		$count = (int) $sales->post_count;
806 806
 		// Cache the results for one hour.
807
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
807
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
808 808
 	}
809 809
 
810 810
 	return $count;
@@ -819,19 +819,19 @@  discard block
 block discarded – undo
819 819
  *
820 820
  * @return bool $ret True if complete, false otherwise.
821 821
  */
822
-function give_is_payment_complete( $payment_id ) {
823
-	$payment = new Give_Payment( $payment_id );
822
+function give_is_payment_complete($payment_id) {
823
+	$payment = new Give_Payment($payment_id);
824 824
 
825 825
 	$ret = false;
826 826
 
827
-	if ( $payment->ID > 0 ) {
827
+	if ($payment->ID > 0) {
828 828
 
829
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
829
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
830 830
 			$ret = true;
831 831
 		}
832 832
 	}
833 833
 
834
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
834
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
835 835
 }
836 836
 
837 837
 /**
@@ -857,49 +857,49 @@  discard block
 block discarded – undo
857 857
  *
858 858
  * @return float $total Total earnings.
859 859
  */
860
-function give_get_total_earnings( $recalculate = false ) {
860
+function give_get_total_earnings($recalculate = false) {
861 861
 
862
-	$total = get_option( 'give_earnings_total', 0 );
862
+	$total = get_option('give_earnings_total', 0);
863 863
 
864 864
 	// Calculate total earnings.
865
-	if ( ! $total || $recalculate ) {
865
+	if ( ! $total || $recalculate) {
866 866
 		global $wpdb;
867 867
 
868 868
 		$total = (float) 0;
869 869
 
870
-		$args = apply_filters( 'give_get_total_earnings_args', array(
870
+		$args = apply_filters('give_get_total_earnings_args', array(
871 871
 			'offset' => 0,
872
-			'number' => - 1,
873
-			'status' => array( 'publish' ),
872
+			'number' => -1,
873
+			'status' => array('publish'),
874 874
 			'fields' => 'ids',
875
-		) );
875
+		));
876 876
 
877
-		$payments = give_get_payments( $args );
878
-		if ( $payments ) {
877
+		$payments = give_get_payments($args);
878
+		if ($payments) {
879 879
 
880 880
 			/**
881 881
 			 * If performing a donation, we need to skip the very last payment in the database,
882 882
 			 * since it calls give_increase_total_earnings() on completion,
883 883
 			 * which results in duplicated earnings for the very first donation.
884 884
 			 */
885
-			if ( did_action( 'give_update_payment_status' ) ) {
886
-				array_pop( $payments );
885
+			if (did_action('give_update_payment_status')) {
886
+				array_pop($payments);
887 887
 			}
888 888
 
889
-			if ( ! empty( $payments ) ) {
890
-				$payments = implode( ',', $payments );
891
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
889
+			if ( ! empty($payments)) {
890
+				$payments = implode(',', $payments);
891
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
892 892
 			}
893 893
 		}
894 894
 
895
-		update_option( 'give_earnings_total', $total, 'no' );
895
+		update_option('give_earnings_total', $total, 'no');
896 896
 	}
897 897
 
898
-	if ( $total < 0 ) {
898
+	if ($total < 0) {
899 899
 		$total = 0; // Don't ever show negative earnings.
900 900
 	}
901 901
 
902
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
902
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
903 903
 }
904 904
 
905 905
 /**
@@ -912,10 +912,10 @@  discard block
 block discarded – undo
912 912
  *
913 913
  * @return float $total  Total earnings.
914 914
  */
915
-function give_increase_total_earnings( $amount = 0 ) {
915
+function give_increase_total_earnings($amount = 0) {
916 916
 	$total = give_get_total_earnings();
917 917
 	$total += $amount;
918
-	update_option( 'give_earnings_total', $total );
918
+	update_option('give_earnings_total', $total);
919 919
 
920 920
 	return $total;
921 921
 }
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
  *
930 930
  * @return float $total Total earnings.
931 931
  */
932
-function give_decrease_total_earnings( $amount = 0 ) {
932
+function give_decrease_total_earnings($amount = 0) {
933 933
 	$total = give_get_total_earnings();
934 934
 	$total -= $amount;
935
-	if ( $total < 0 ) {
935
+	if ($total < 0) {
936 936
 		$total = 0;
937 937
 	}
938
-	update_option( 'give_earnings_total', $total );
938
+	update_option('give_earnings_total', $total);
939 939
 
940 940
 	return $total;
941 941
 }
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
  *
952 952
  * @return mixed $meta Payment Meta.
953 953
  */
954
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
955
-	$payment = new Give_Payment( $payment_id );
954
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
955
+	$payment = new Give_Payment($payment_id);
956 956
 
957
-	return $payment->get_meta( $meta_key, $single );
957
+	return $payment->get_meta($meta_key, $single);
958 958
 }
959 959
 
960 960
 /**
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
  *
968 968
  * @return mixed Meta ID if successful, false if unsuccessful.
969 969
  */
970
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
971
-	$payment = new Give_Payment( $payment_id );
970
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
971
+	$payment = new Give_Payment($payment_id);
972 972
 
973
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
973
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
974 974
 }
975 975
 
976 976
 /**
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
  *
983 983
  * @return string $user_info User Info Meta Values.
984 984
  */
985
-function give_get_payment_meta_user_info( $payment_id ) {
986
-	$payment = new Give_Payment( $payment_id );
985
+function give_get_payment_meta_user_info($payment_id) {
986
+	$payment = new Give_Payment($payment_id);
987 987
 
988 988
 	return $payment->user_info;
989 989
 }
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
  *
1000 1000
  * @return int $form_id Form ID.
1001 1001
  */
1002
-function give_get_payment_form_id( $payment_id ) {
1003
-	$payment = new Give_Payment( $payment_id );
1002
+function give_get_payment_form_id($payment_id) {
1003
+	$payment = new Give_Payment($payment_id);
1004 1004
 
1005 1005
 	return $payment->form_id;
1006 1006
 }
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
  *
1015 1015
  * @return string $email User email.
1016 1016
  */
1017
-function give_get_payment_user_email( $payment_id ) {
1018
-	$payment = new Give_Payment( $payment_id );
1017
+function give_get_payment_user_email($payment_id) {
1018
+	$payment = new Give_Payment($payment_id);
1019 1019
 
1020 1020
 	return $payment->email;
1021 1021
 }
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1031 1031
  */
1032
-function give_is_guest_payment( $payment_id ) {
1033
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1034
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1032
+function give_is_guest_payment($payment_id) {
1033
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1034
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1035 1035
 
1036
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1036
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1037 1037
 }
1038 1038
 
1039 1039
 /**
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
  *
1046 1046
  * @return int $user_id User ID.
1047 1047
  */
1048
-function give_get_payment_user_id( $payment_id ) {
1049
-	$payment = new Give_Payment( $payment_id );
1048
+function give_get_payment_user_id($payment_id) {
1049
+	$payment = new Give_Payment($payment_id);
1050 1050
 
1051 1051
 	return $payment->user_id;
1052 1052
 }
@@ -1060,8 +1060,8 @@  discard block
 block discarded – undo
1060 1060
  *
1061 1061
  * @return int $customer_id Customer ID.
1062 1062
  */
1063
-function give_get_payment_customer_id( $payment_id ) {
1064
-	$payment = new Give_Payment( $payment_id );
1063
+function give_get_payment_customer_id($payment_id) {
1064
+	$payment = new Give_Payment($payment_id);
1065 1065
 
1066 1066
 	return $payment->customer_id;
1067 1067
 }
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
  *
1076 1076
  * @return string $ip User IP.
1077 1077
  */
1078
-function give_get_payment_user_ip( $payment_id ) {
1079
-	$payment = new Give_Payment( $payment_id );
1078
+function give_get_payment_user_ip($payment_id) {
1079
+	$payment = new Give_Payment($payment_id);
1080 1080
 
1081 1081
 	return $payment->ip;
1082 1082
 }
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
  *
1091 1091
  * @return string $date The date the payment was completed.
1092 1092
  */
1093
-function give_get_payment_completed_date( $payment_id = 0 ) {
1094
-	$payment = new Give_Payment( $payment_id );
1093
+function give_get_payment_completed_date($payment_id = 0) {
1094
+	$payment = new Give_Payment($payment_id);
1095 1095
 
1096 1096
 	return $payment->completed_date;
1097 1097
 }
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
  *
1106 1106
  * @return string $gateway Gateway.
1107 1107
  */
1108
-function give_get_payment_gateway( $payment_id ) {
1109
-	$payment = new Give_Payment( $payment_id );
1108
+function give_get_payment_gateway($payment_id) {
1109
+	$payment = new Give_Payment($payment_id);
1110 1110
 
1111 1111
 	return $payment->gateway;
1112 1112
 }
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
  *
1121 1121
  * @return string $currency The currency code.
1122 1122
  */
1123
-function give_get_payment_currency_code( $payment_id = 0 ) {
1124
-	$payment = new Give_Payment( $payment_id );
1123
+function give_get_payment_currency_code($payment_id = 0) {
1124
+	$payment = new Give_Payment($payment_id);
1125 1125
 
1126 1126
 	return $payment->currency;
1127 1127
 }
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
  *
1136 1136
  * @return string $currency The currency name.
1137 1137
  */
1138
-function give_get_payment_currency( $payment_id = 0 ) {
1139
-	$currency = give_get_payment_currency_code( $payment_id );
1138
+function give_get_payment_currency($payment_id = 0) {
1139
+	$currency = give_get_payment_currency_code($payment_id);
1140 1140
 
1141
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1141
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1142 1142
 }
1143 1143
 
1144 1144
 /**
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
  *
1151 1151
  * @return string $key Donation key.
1152 1152
  */
1153
-function give_get_payment_key( $payment_id = 0 ) {
1154
-	$payment = new Give_Payment( $payment_id );
1153
+function give_get_payment_key($payment_id = 0) {
1154
+	$payment = new Give_Payment($payment_id);
1155 1155
 
1156 1156
 	return $payment->key;
1157 1157
 }
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
  *
1168 1168
  * @return string $number Payment order number.
1169 1169
  */
1170
-function give_get_payment_number( $payment_id = 0 ) {
1171
-	$payment = new Give_Payment( $payment_id );
1170
+function give_get_payment_number($payment_id = 0) {
1171
+	$payment = new Give_Payment($payment_id);
1172 1172
 
1173 1173
 	return $payment->number;
1174 1174
 }
@@ -1182,23 +1182,23 @@  discard block
 block discarded – undo
1182 1182
  *
1183 1183
  * @return string      The formatted payment number.
1184 1184
  */
1185
-function give_format_payment_number( $number ) {
1185
+function give_format_payment_number($number) {
1186 1186
 
1187
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1187
+	if ( ! give_get_option('enable_sequential')) {
1188 1188
 		return $number;
1189 1189
 	}
1190 1190
 
1191
-	if ( ! is_numeric( $number ) ) {
1191
+	if ( ! is_numeric($number)) {
1192 1192
 		return $number;
1193 1193
 	}
1194 1194
 
1195
-	$prefix  = give_get_option( 'sequential_prefix' );
1196
-	$number  = absint( $number );
1197
-	$postfix = give_get_option( 'sequential_postfix' );
1195
+	$prefix  = give_get_option('sequential_prefix');
1196
+	$number  = absint($number);
1197
+	$postfix = give_get_option('sequential_postfix');
1198 1198
 
1199
-	$formatted_number = $prefix . $number . $postfix;
1199
+	$formatted_number = $prefix.$number.$postfix;
1200 1200
 
1201
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1201
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1202 1202
 }
1203 1203
 
1204 1204
 /**
@@ -1211,17 +1211,17 @@  discard block
 block discarded – undo
1211 1211
  */
1212 1212
 function give_get_next_payment_number() {
1213 1213
 
1214
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1214
+	if ( ! give_get_option('enable_sequential')) {
1215 1215
 		return false;
1216 1216
 	}
1217 1217
 
1218
-	$number           = get_option( 'give_last_payment_number' );
1219
-	$start            = give_get_option( 'sequential_start', 1 );
1218
+	$number           = get_option('give_last_payment_number');
1219
+	$start            = give_get_option('sequential_start', 1);
1220 1220
 	$increment_number = true;
1221 1221
 
1222
-	if ( false !== $number ) {
1222
+	if (false !== $number) {
1223 1223
 
1224
-		if ( empty( $number ) ) {
1224
+		if (empty($number)) {
1225 1225
 
1226 1226
 			$number           = $start;
1227 1227
 			$increment_number = false;
@@ -1230,24 +1230,24 @@  discard block
 block discarded – undo
1230 1230
 	} else {
1231 1231
 
1232 1232
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1233
-		$payments     = new Give_Payments_Query( array(
1233
+		$payments = new Give_Payments_Query(array(
1234 1234
 			'number'  => 1,
1235 1235
 			'order'   => 'DESC',
1236 1236
 			'orderby' => 'ID',
1237 1237
 			'output'  => 'posts',
1238 1238
 			'fields'  => 'ids',
1239
-		) );
1239
+		));
1240 1240
 		$last_payment = $payments->get_payments();
1241 1241
 
1242
-		if ( ! empty( $last_payment ) ) {
1242
+		if ( ! empty($last_payment)) {
1243 1243
 
1244
-			$number = give_get_payment_number( $last_payment[0] );
1244
+			$number = give_get_payment_number($last_payment[0]);
1245 1245
 
1246 1246
 		}
1247 1247
 
1248
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1248
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1249 1249
 
1250
-			$number = give_remove_payment_prefix_postfix( $number );
1250
+			$number = give_remove_payment_prefix_postfix($number);
1251 1251
 
1252 1252
 		} else {
1253 1253
 
@@ -1256,13 +1256,13 @@  discard block
 block discarded – undo
1256 1256
 		}
1257 1257
 	}
1258 1258
 
1259
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1259
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1260 1260
 
1261
-	if ( $increment_number ) {
1262
-		$number ++;
1261
+	if ($increment_number) {
1262
+		$number++;
1263 1263
 	}
1264 1264
 
1265
-	return apply_filters( 'give_get_next_payment_number', $number );
1265
+	return apply_filters('give_get_next_payment_number', $number);
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1274,25 +1274,25 @@  discard block
 block discarded – undo
1274 1274
  *
1275 1275
  * @return string The new Payment number without prefix and postfix.
1276 1276
  */
1277
-function give_remove_payment_prefix_postfix( $number ) {
1277
+function give_remove_payment_prefix_postfix($number) {
1278 1278
 
1279
-	$prefix  = give_get_option( 'sequential_prefix' );
1280
-	$postfix = give_get_option( 'sequential_postfix' );
1279
+	$prefix  = give_get_option('sequential_prefix');
1280
+	$postfix = give_get_option('sequential_postfix');
1281 1281
 
1282 1282
 	// Remove prefix.
1283
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1283
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1284 1284
 
1285 1285
 	// Remove the postfix.
1286
-	$length      = strlen( $number );
1287
-	$postfix_pos = strrpos( $number, $postfix );
1288
-	if ( false !== $postfix_pos ) {
1289
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1286
+	$length      = strlen($number);
1287
+	$postfix_pos = strrpos($number, $postfix);
1288
+	if (false !== $postfix_pos) {
1289
+		$number = substr_replace($number, '', $postfix_pos, $length);
1290 1290
 	}
1291 1291
 
1292 1292
 	// Ensure it's a whole number.
1293
-	$number = intval( $number );
1293
+	$number = intval($number);
1294 1294
 
1295
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1295
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1296 1296
 
1297 1297
 }
1298 1298
 
@@ -1309,10 +1309,10 @@  discard block
 block discarded – undo
1309 1309
  *
1310 1310
  * @return string $amount Fully formatted payment amount.
1311 1311
  */
1312
-function give_payment_amount( $payment_id = 0 ) {
1313
-	$amount = give_get_payment_amount( $payment_id );
1312
+function give_payment_amount($payment_id = 0) {
1313
+	$amount = give_get_payment_amount($payment_id);
1314 1314
 
1315
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1315
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1316 1316
 }
1317 1317
 
1318 1318
 /**
@@ -1325,11 +1325,11 @@  discard block
 block discarded – undo
1325 1325
  *
1326 1326
  * @return mixed|void
1327 1327
  */
1328
-function give_get_payment_amount( $payment_id ) {
1328
+function give_get_payment_amount($payment_id) {
1329 1329
 
1330
-	$payment = new Give_Payment( $payment_id );
1330
+	$payment = new Give_Payment($payment_id);
1331 1331
 
1332
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1332
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1333 1333
 }
1334 1334
 
1335 1335
 /**
@@ -1346,10 +1346,10 @@  discard block
 block discarded – undo
1346 1346
  *
1347 1347
  * @return array Fully formatted payment subtotal.
1348 1348
  */
1349
-function give_payment_subtotal( $payment_id = 0 ) {
1350
-	$subtotal = give_get_payment_subtotal( $payment_id );
1349
+function give_payment_subtotal($payment_id = 0) {
1350
+	$subtotal = give_get_payment_subtotal($payment_id);
1351 1351
 
1352
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1352
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1353 1353
 }
1354 1354
 
1355 1355
 /**
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
  *
1364 1364
  * @return float $subtotal Subtotal for payment (non formatted).
1365 1365
  */
1366
-function give_get_payment_subtotal( $payment_id = 0 ) {
1367
-	$payment = new G_Payment( $payment_id );
1366
+function give_get_payment_subtotal($payment_id = 0) {
1367
+	$payment = new G_Payment($payment_id);
1368 1368
 
1369 1369
 	return $payment->subtotal;
1370 1370
 }
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
  *
1380 1380
  * @return mixed array if payment fees found, false otherwise.
1381 1381
  */
1382
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1383
-	$payment = new Give_Payment( $payment_id );
1382
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1383
+	$payment = new Give_Payment($payment_id);
1384 1384
 
1385
-	return $payment->get_fees( $type );
1385
+	return $payment->get_fees($type);
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1394,8 +1394,8 @@  discard block
 block discarded – undo
1394 1394
  *
1395 1395
  * @return string The donation ID.
1396 1396
  */
1397
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1398
-	$payment = new Give_Payment( $payment_id );
1397
+function give_get_payment_transaction_id($payment_id = 0) {
1398
+	$payment = new Give_Payment($payment_id);
1399 1399
 
1400 1400
 	return $payment->transaction_id;
1401 1401
 }
@@ -1410,15 +1410,15 @@  discard block
 block discarded – undo
1410 1410
  *
1411 1411
  * @return bool|mixed
1412 1412
  */
1413
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1413
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1414 1414
 
1415
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1415
+	if (empty($payment_id) || empty($transaction_id)) {
1416 1416
 		return false;
1417 1417
 	}
1418 1418
 
1419
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1419
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1420 1420
 
1421
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1421
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1422 1422
 }
1423 1423
 
1424 1424
 /**
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
  *
1432 1432
  * @return int $purchase Donation ID.
1433 1433
  */
1434
-function give_get_purchase_id_by_key( $key ) {
1434
+function give_get_purchase_id_by_key($key) {
1435 1435
 	global $wpdb;
1436 1436
 
1437
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1437
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1438 1438
 
1439
-	if ( $purchase != null ) {
1439
+	if ($purchase != null) {
1440 1440
 		return $purchase;
1441 1441
 	}
1442 1442
 
@@ -1454,12 +1454,12 @@  discard block
 block discarded – undo
1454 1454
  *
1455 1455
  * @return int $purchase Donation ID.
1456 1456
  */
1457
-function give_get_purchase_id_by_transaction_id( $key ) {
1457
+function give_get_purchase_id_by_transaction_id($key) {
1458 1458
 	global $wpdb;
1459 1459
 
1460
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1460
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1461 1461
 
1462
-	if ( $purchase != null ) {
1462
+	if ($purchase != null) {
1463 1463
 		return $purchase;
1464 1464
 	}
1465 1465
 
@@ -1476,19 +1476,19 @@  discard block
 block discarded – undo
1476 1476
  *
1477 1477
  * @return array $notes Donation Notes
1478 1478
  */
1479
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1479
+function give_get_payment_notes($payment_id = 0, $search = '') {
1480 1480
 
1481
-	if ( empty( $payment_id ) && empty( $search ) ) {
1481
+	if (empty($payment_id) && empty($search)) {
1482 1482
 		return false;
1483 1483
 	}
1484 1484
 
1485
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1486
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1485
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1486
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1487 1487
 
1488
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1488
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1489 1489
 
1490
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1491
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1490
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1491
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1492 1492
 
1493 1493
 	return $notes;
1494 1494
 }
@@ -1504,8 +1504,8 @@  discard block
 block discarded – undo
1504 1504
  *
1505 1505
  * @return int The new note ID
1506 1506
  */
1507
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1508
-	if ( empty( $payment_id ) ) {
1507
+function give_insert_payment_note($payment_id = 0, $note = '') {
1508
+	if (empty($payment_id)) {
1509 1509
 		return false;
1510 1510
 	}
1511 1511
 
@@ -1517,14 +1517,14 @@  discard block
 block discarded – undo
1517 1517
 	 * @param int $payment_id Payment ID.
1518 1518
 	 * @param string $note The note.
1519 1519
 	 */
1520
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1520
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1521 1521
 
1522
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1522
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1523 1523
 		'comment_post_ID'      => $payment_id,
1524 1524
 		'comment_content'      => $note,
1525 1525
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1526
-		'comment_date'         => current_time( 'mysql' ),
1527
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1526
+		'comment_date'         => current_time('mysql'),
1527
+		'comment_date_gmt'     => current_time('mysql', 1),
1528 1528
 		'comment_approved'     => 1,
1529 1529
 		'comment_parent'       => 0,
1530 1530
 		'comment_author'       => '',
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 		'comment_author_email' => '',
1534 1534
 		'comment_type'         => 'give_payment_note',
1535 1535
 
1536
-	) ) );
1536
+	)));
1537 1537
 
1538 1538
 	/**
1539 1539
 	 * Fires after payment note inserted.
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 	 * @param int $payment_id Payment ID.
1545 1545
 	 * @param string $note The note.
1546 1546
 	 */
1547
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1547
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1548 1548
 
1549 1549
 	return $note_id;
1550 1550
 }
@@ -1559,8 +1559,8 @@  discard block
 block discarded – undo
1559 1559
  *
1560 1560
  * @return bool True on success, false otherwise.
1561 1561
  */
1562
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1563
-	if ( empty( $comment_id ) ) {
1562
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1563
+	if (empty($comment_id)) {
1564 1564
 		return false;
1565 1565
 	}
1566 1566
 
@@ -1572,9 +1572,9 @@  discard block
 block discarded – undo
1572 1572
 	 * @param int $comment_id Note ID.
1573 1573
 	 * @param int $payment_id Payment ID.
1574 1574
 	 */
1575
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1575
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1576 1576
 
1577
-	$ret = wp_delete_comment( $comment_id, true );
1577
+	$ret = wp_delete_comment($comment_id, true);
1578 1578
 
1579 1579
 	/**
1580 1580
 	 * Fires after donation note deleted.
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 	 * @param int $comment_id Note ID.
1585 1585
 	 * @param int $payment_id Payment ID.
1586 1586
 	 */
1587
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1587
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1588 1588
 
1589 1589
 	return $ret;
1590 1590
 }
@@ -1599,34 +1599,34 @@  discard block
 block discarded – undo
1599 1599
  *
1600 1600
  * @return string
1601 1601
  */
1602
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1602
+function give_get_payment_note_html($note, $payment_id = 0) {
1603 1603
 
1604
-	if ( is_numeric( $note ) ) {
1605
-		$note = get_comment( $note );
1604
+	if (is_numeric($note)) {
1605
+		$note = get_comment($note);
1606 1606
 	}
1607 1607
 
1608
-	if ( ! empty( $note->user_id ) ) {
1609
-		$user = get_userdata( $note->user_id );
1608
+	if ( ! empty($note->user_id)) {
1609
+		$user = get_userdata($note->user_id);
1610 1610
 		$user = $user->display_name;
1611 1611
 	} else {
1612
-		$user = esc_html__( 'System', 'give' );
1612
+		$user = esc_html__('System', 'give');
1613 1613
 	}
1614 1614
 
1615
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1615
+	$date_format = give_date_format().', '.get_option('time_format');
1616 1616
 
1617
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1617
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1618 1618
 		'give-action' => 'delete_payment_note',
1619 1619
 		'note_id'     => $note->comment_ID,
1620 1620
 		'payment_id'  => $payment_id,
1621
-	) ),
1622
-		'give_delete_payment_note_' . $note->comment_ID
1621
+	)),
1622
+		'give_delete_payment_note_'.$note->comment_ID
1623 1623
 	);
1624 1624
 
1625
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1625
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1626 1626
 	$note_html .= '<p>';
1627
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1627
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1628 1628
 	$note_html .= $note->comment_content;
1629
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1629
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1630 1630
 	$note_html .= '</p>';
1631 1631
 	$note_html .= '</div>';
1632 1632
 
@@ -1644,18 +1644,18 @@  discard block
 block discarded – undo
1644 1644
  *
1645 1645
  * @return void
1646 1646
  */
1647
-function give_hide_payment_notes( $query ) {
1648
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1649
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1650
-		if ( ! is_array( $types ) ) {
1651
-			$types = array( $types );
1647
+function give_hide_payment_notes($query) {
1648
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1649
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1650
+		if ( ! is_array($types)) {
1651
+			$types = array($types);
1652 1652
 		}
1653 1653
 		$types[]                           = 'give_payment_note';
1654 1654
 		$query->query_vars['type__not_in'] = $types;
1655 1655
 	}
1656 1656
 }
1657 1657
 
1658
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1658
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1659 1659
 
1660 1660
 /**
1661 1661
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1667,15 +1667,15 @@  discard block
 block discarded – undo
1667 1667
  *
1668 1668
  * @return array $clauses Updated comment clauses.
1669 1669
  */
1670
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1671
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1670
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1671
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1672 1672
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1673 1673
 	}
1674 1674
 
1675 1675
 	return $clauses;
1676 1676
 }
1677 1677
 
1678
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1678
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1679 1679
 
1680 1680
 
1681 1681
 /**
@@ -1688,15 +1688,15 @@  discard block
 block discarded – undo
1688 1688
  *
1689 1689
  * @return string $where
1690 1690
  */
1691
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1691
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1692 1692
 	global $wpdb;
1693 1693
 
1694
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1694
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1695 1695
 
1696 1696
 	return $where;
1697 1697
 }
1698 1698
 
1699
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1699
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1700 1700
 
1701 1701
 
1702 1702
 /**
@@ -1710,32 +1710,32 @@  discard block
 block discarded – undo
1710 1710
  *
1711 1711
  * @return array Array of comment counts.
1712 1712
  */
1713
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1713
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1714 1714
 	global $wpdb, $pagenow;
1715 1715
 
1716
-	if ( 'index.php' != $pagenow ) {
1716
+	if ('index.php' != $pagenow) {
1717 1717
 		return $stats;
1718 1718
 	}
1719 1719
 
1720 1720
 	$post_id = (int) $post_id;
1721 1721
 
1722
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1722
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1723 1723
 		return $stats;
1724 1724
 	}
1725 1725
 
1726
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1726
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1727 1727
 
1728
-	if ( false !== $stats ) {
1728
+	if (false !== $stats) {
1729 1729
 		return $stats;
1730 1730
 	}
1731 1731
 
1732 1732
 	$where = 'WHERE comment_type != "give_payment_note"';
1733 1733
 
1734
-	if ( $post_id > 0 ) {
1735
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1734
+	if ($post_id > 0) {
1735
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1736 1736
 	}
1737 1737
 
1738
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1738
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1739 1739
 
1740 1740
 	$total    = 0;
1741 1741
 	$approved = array(
@@ -1745,30 +1745,30 @@  discard block
 block discarded – undo
1745 1745
 		'trash'        => 'trash',
1746 1746
 		'post-trashed' => 'post-trashed',
1747 1747
 	);
1748
-	foreach ( (array) $count as $row ) {
1748
+	foreach ((array) $count as $row) {
1749 1749
 		// Don't count post-trashed toward totals.
1750
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1750
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1751 1751
 			$total += $row['num_comments'];
1752 1752
 		}
1753
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1754
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1753
+		if (isset($approved[$row['comment_approved']])) {
1754
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1755 1755
 		}
1756 1756
 	}
1757 1757
 
1758 1758
 	$stats['total_comments'] = $total;
1759
-	foreach ( $approved as $key ) {
1760
-		if ( empty( $stats[ $key ] ) ) {
1761
-			$stats[ $key ] = 0;
1759
+	foreach ($approved as $key) {
1760
+		if (empty($stats[$key])) {
1761
+			$stats[$key] = 0;
1762 1762
 		}
1763 1763
 	}
1764 1764
 
1765 1765
 	$stats = (object) $stats;
1766
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1766
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1767 1767
 
1768 1768
 	return $stats;
1769 1769
 }
1770 1770
 
1771
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1771
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1772 1772
 
1773 1773
 
1774 1774
 /**
@@ -1781,9 +1781,9 @@  discard block
 block discarded – undo
1781 1781
  *
1782 1782
  * @return string $where Modified where clause.
1783 1783
  */
1784
-function give_filter_where_older_than_week( $where = '' ) {
1784
+function give_filter_where_older_than_week($where = '') {
1785 1785
 	// Payments older than one week.
1786
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1786
+	$start = date('Y-m-d', strtotime('-7 days'));
1787 1787
 	$where .= " AND post_date <= '{$start}'";
1788 1788
 
1789 1789
 	return $where;
@@ -1803,38 +1803,38 @@  discard block
 block discarded – undo
1803 1803
  *
1804 1804
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1805 1805
  */
1806
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1806
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1807 1807
 
1808
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1809
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1810
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1808
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1809
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1810
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1811 1811
 
1812
-	if ( $only_level == true ) {
1812
+	if ($only_level == true) {
1813 1813
 		$form_title = '';
1814 1814
 	}
1815 1815
 
1816 1816
 	//If multi-level, append to the form title.
1817
-	if ( give_has_variable_prices( $form_id ) ) {
1817
+	if (give_has_variable_prices($form_id)) {
1818 1818
 
1819 1819
 		//Only add separator if there is a form title.
1820
-		if ( ! empty( $form_title ) ) {
1821
-			$form_title .= ' ' . $separator . ' ';
1820
+		if ( ! empty($form_title)) {
1821
+			$form_title .= ' '.$separator.' ';
1822 1822
 		}
1823 1823
 
1824 1824
 		$form_title .= '<span class="donation-level-text-wrap">';
1825 1825
 
1826
-		if ( $price_id == 'custom' ) {
1827
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
1828
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1826
+		if ($price_id == 'custom') {
1827
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
1828
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1829 1829
 		} else {
1830
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1830
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1831 1831
 		}
1832 1832
 
1833 1833
 		$form_title .= '</span>';
1834 1834
 
1835 1835
 	}
1836 1836
 
1837
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1837
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1838 1838
 
1839 1839
 }
1840 1840
 
@@ -1848,20 +1848,20 @@  discard block
 block discarded – undo
1848 1848
  *
1849 1849
  * @return string $price_id
1850 1850
  */
1851
-function give_get_price_id( $form_id, $price ) {
1851
+function give_get_price_id($form_id, $price) {
1852 1852
 
1853 1853
 	$price_id = 0;
1854 1854
 
1855
-	if ( give_has_variable_prices( $form_id ) ) {
1855
+	if (give_has_variable_prices($form_id)) {
1856 1856
 
1857
-		$levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1857
+		$levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1858 1858
 
1859
-		foreach ( $levels as $level ) {
1859
+		foreach ($levels as $level) {
1860 1860
 
1861
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1861
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1862 1862
 
1863 1863
 			// Check that this indeed the recurring price.
1864
-			if ( $level_amount == $price ) {
1864
+			if ($level_amount == $price) {
1865 1865
 
1866 1866
 				$price_id = $level['_give_id']['level_id'];
1867 1867
 
@@ -1886,10 +1886,10 @@  discard block
 block discarded – undo
1886 1886
  *
1887 1887
  * @return string|void
1888 1888
  */
1889
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1890
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1889
+function give_get_form_dropdown($args = array(), $echo = false) {
1890
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1891 1891
 
1892
-	if ( ! $echo ) {
1892
+	if ( ! $echo) {
1893 1893
 		return $form_dropdown_html;
1894 1894
 	}
1895 1895
 
@@ -1906,17 +1906,17 @@  discard block
 block discarded – undo
1906 1906
  *
1907 1907
  * @return string|bool
1908 1908
  */
1909
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1909
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1910 1910
 
1911 1911
 	// Check for give form id.
1912
-	if ( empty( $args['id'] ) ) {
1912
+	if (empty($args['id'])) {
1913 1913
 		return false;
1914 1914
 	}
1915 1915
 
1916
-	$form = new Give_Donate_Form( $args['id'] );
1916
+	$form = new Give_Donate_Form($args['id']);
1917 1917
 
1918 1918
 	// Check if form has variable prices or not.
1919
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1919
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1920 1920
 		return false;
1921 1921
 	}
1922 1922
 
@@ -1924,22 +1924,22 @@  discard block
 block discarded – undo
1924 1924
 	$variable_price_options = array();
1925 1925
 
1926 1926
 	// Check if multi donation form support custom donation or not.
1927
-	if ( $form->is_custom_price_mode() ) {
1928
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1927
+	if ($form->is_custom_price_mode()) {
1928
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1929 1929
 	}
1930 1930
 
1931 1931
 	// Get variable price and ID from variable price array.
1932
-	foreach ( $variable_prices as $variable_price ) {
1933
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) );
1932
+	foreach ($variable_prices as $variable_price) {
1933
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount']));
1934 1934
 	}
1935 1935
 
1936 1936
 	// Update options.
1937
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1937
+	$args = array_merge($args, array('options' => $variable_price_options));
1938 1938
 
1939 1939
 	// Generate select html.
1940
-	$form_dropdown_html = Give()->html->select( $args );
1940
+	$form_dropdown_html = Give()->html->select($args);
1941 1941
 
1942
-	if ( ! $echo ) {
1942
+	if ( ! $echo) {
1943 1943
 		return $form_dropdown_html;
1944 1944
 	}
1945 1945
 
@@ -1958,16 +1958,16 @@  discard block
 block discarded – undo
1958 1958
  *
1959 1959
  * @return string
1960 1960
  */
1961
-function give_get_payment_meta_price_id( $payment_meta ) {
1961
+function give_get_payment_meta_price_id($payment_meta) {
1962 1962
 
1963
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1963
+	if (isset($payment_meta['give_price_id'])) {
1964 1964
 		$price_id = $payment_meta['give_price_id'];
1965
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1965
+	} elseif (isset($payment_meta['price_id'])) {
1966 1966
 		$price_id = $payment_meta['price_id'];
1967 1967
 	} else {
1968
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1968
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1969 1969
 	}
1970 1970
 
1971
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1971
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1972 1972
 
1973 1973
 }
1974 1974
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), - 1 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), - 1);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key = sanitize_key($key);
181 181
 
182
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
182
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
183 183
 
184 184
 	}
185 185
 
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return string        Session variable.
198 198
 	 */
199
-	public function set( $key, $value ) {
199
+	public function set($key, $value) {
200 200
 
201
-		$key = sanitize_key( $key );
201
+		$key = sanitize_key($key);
202 202
 
203
-		if ( is_array( $value ) ) {
204
-			$this->session[ $key ] = serialize( $value );
203
+		if (is_array($value)) {
204
+			$this->session[$key] = serialize($value);
205 205
 		} else {
206
-			$this->session[ $key ] = $value;
206
+			$this->session[$key] = $value;
207 207
 		}
208 208
 
209
-		if ( $this->use_php_sessions ) {
210
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
209
+		if ($this->use_php_sessions) {
210
+			$_SESSION['give'.$this->prefix] = $this->session;
211 211
 		}
212 212
 
213
-		return $this->session[ $key ];
213
+		return $this->session[$key];
214 214
 	}
215 215
 
216 216
 	/**
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 	 * @hook
225 225
 	 */
226 226
 	public function set_session_cookies() {
227
-		if ( ! headers_sent() ) {
228
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
229
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
230
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
227
+		if ( ! headers_sent()) {
228
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
229
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
230
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
231 231
 		}
232 232
 	}
233 233
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function set_expiration_variant_time() {
245 245
 
246
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
246
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	public function set_expiration_time() {
260 260
 
261
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
261
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
262 262
 	}
263 263
 
264 264
 	/**
@@ -276,21 +276,21 @@  discard block
 block discarded – undo
276 276
 		$ret = false;
277 277
 
278 278
 		// If the database variable is already set, no need to run auto detection.
279
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
279
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
280 280
 
281
-		if ( ! $give_use_php_sessions ) {
281
+		if ( ! $give_use_php_sessions) {
282 282
 
283 283
 			// Attempt to detect if the server supports PHP sessions.
284
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
284
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
285 285
 
286
-				$this->set( 'give_use_php_sessions', 1 );
286
+				$this->set('give_use_php_sessions', 1);
287 287
 
288
-				if ( $this->get( 'give_use_php_sessions' ) ) {
288
+				if ($this->get('give_use_php_sessions')) {
289 289
 
290 290
 					$ret = true;
291 291
 
292 292
 					// Set the database option.
293
-					update_option( 'give_use_php_sessions', true );
293
+					update_option('give_use_php_sessions', true);
294 294
 
295 295
 				}
296 296
 			}
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 
302 302
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
303
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
303
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
304 304
 			$ret = true;
305
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
305
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
306 306
 			$ret = false;
307 307
 		}
308 308
 
309
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
309
+		return (bool) apply_filters('give_use_php_sessions', $ret);
310 310
 	}
311 311
 
312 312
 	/**
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$start_session = true;
325 325
 
326
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
326
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
327 327
 
328
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
328
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
329 329
 				'feed',
330 330
 				'feed',
331 331
 				'feed/rss',
@@ -333,21 +333,21 @@  discard block
 block discarded – undo
333 333
 				'feed/rdf',
334 334
 				'feed/atom',
335 335
 				'comments/feed/',
336
-			) );
337
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
338
-			$uri       = untrailingslashit( $uri );
339
-			if ( in_array( $uri, $blacklist ) ) {
336
+			));
337
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
338
+			$uri       = untrailingslashit($uri);
339
+			if (in_array($uri, $blacklist)) {
340 340
 				$start_session = false;
341 341
 			}
342
-			if ( false !== strpos( $uri, 'feed=' ) ) {
342
+			if (false !== strpos($uri, 'feed=')) {
343 343
 				$start_session = false;
344 344
 			}
345
-			if ( is_admin() ) {
345
+			if (is_admin()) {
346 346
 				$start_session = false;
347 347
 			}
348 348
 		}
349 349
 
350
-		return apply_filters( 'give_start_session', $start_session );
350
+		return apply_filters('give_start_session', $start_session);
351 351
 	}
352 352
 
353 353
 	/**
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	public function maybe_start_session() {
365 365
 
366
-		if ( ! $this->should_start_session() ) {
366
+		if ( ! $this->should_start_session()) {
367 367
 			return;
368 368
 		}
369 369
 
370
-		if ( ! session_id() && ! headers_sent() ) {
370
+		if ( ! session_id() && ! headers_sent()) {
371 371
 			session_start();
372 372
 		}
373 373
 
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 
387 387
 		$expiration = false;
388 388
 
389
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
389
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
390 390
 
391
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
391
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
392 392
 
393 393
 		}
394 394
 
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array $user_info Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );
145
+	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $purchase_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
158
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,29 +175,29 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
178
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Customer( get_current_user_id(), true );
183
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
184
+		$customer = new Give_Customer(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187 187
 		if (
188 188
 			$submitted_email !== $customer->email
189
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
189
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
190 190
 		) {
191
-			$found_customer = new Give_Customer( $submitted_email );
191
+			$found_customer = new Give_Customer($submitted_email);
192 192
 
193
-			if ( $found_customer->id > 0 ) {
194
-				give_set_error( 'give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.'), $customer->email, $submitted_email) );
193
+			if ($found_customer->id > 0) {
194
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.'), $customer->email, $submitted_email));
195 195
 			}
196 196
 		}
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
200
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
201 201
 
202 202
 /**
203 203
  * Process the checkout login form
@@ -208,37 +208,37 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_process_form_login() {
210 210
 
211
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
212 212
 
213 213
 	$user_data = give_purchase_form_validate_user_login();
214 214
 
215
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
216
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
217 217
 			/**
218 218
 			 * Fires when AJAX sends back errors from the donation form.
219 219
 			 *
220 220
 			 * @since 1.0
221 221
 			 */
222
-			do_action( 'give_ajax_donation_errors' );
222
+			do_action('give_ajax_donation_errors');
223 223
 			give_die();
224 224
 		} else {
225
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
225
+			wp_redirect($_SERVER['HTTP_REFERER']);
226 226
 			exit;
227 227
 		}
228 228
 	}
229 229
 
230
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
230
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
231 231
 
232
-	if ( $is_ajax ) {
232
+	if ($is_ajax) {
233 233
 		echo 'success';
234 234
 		give_die();
235 235
 	} else {
236
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
236
+		wp_redirect($_SERVER['HTTP_REFERER']);
237 237
 	}
238 238
 }
239 239
 
240
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
241
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
240
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
241
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
242 242
 
243 243
 /**
244 244
  * Donation Form Validate Fields
@@ -250,55 +250,55 @@  discard block
 block discarded – undo
250 250
 function give_purchase_form_validate_fields() {
251 251
 
252 252
 	// Check if there is $_POST
253
-	if ( empty( $_POST ) ) {
253
+	if (empty($_POST)) {
254 254
 		return false;
255 255
 	}
256 256
 
257
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
257
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
258 258
 
259 259
 	// Start an array to collect valid data
260 260
 	$valid_data = array(
261 261
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
262
-		'need_new_user'    => false,     // New user flag
263
-		'need_user_login'  => false,     // Login user flag
264
-		'logged_user_data' => array(),   // Logged user collected data
265
-		'new_user_data'    => array(),   // New user collected data
266
-		'login_user_data'  => array(),   // Login user collected data
267
-		'guest_user_data'  => array(),   // Guest user collected data
268
-		'cc_info'          => give_purchase_form_validate_cc(),// Credit card info
262
+		'need_new_user'    => false, // New user flag
263
+		'need_user_login'  => false, // Login user flag
264
+		'logged_user_data' => array(), // Logged user collected data
265
+		'new_user_data'    => array(), // New user collected data
266
+		'login_user_data'  => array(), // Login user collected data
267
+		'guest_user_data'  => array(), // Guest user collected data
268
+		'cc_info'          => give_purchase_form_validate_cc(), // Credit card info
269 269
 	);
270 270
 
271 271
 	// Validate Honeypot First
272
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
273
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
272
+	if ( ! empty($_POST['give-honeypot'])) {
273
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
274 274
 	}
275 275
 
276 276
 	// Validate agree to terms
277
-	if ( give_is_terms_enabled( $form_id ) ) {
277
+	if (give_is_terms_enabled($form_id)) {
278 278
 		give_purchase_form_validate_agree_to_terms();
279 279
 	}
280 280
 
281 281
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
282 282
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
283 283
 	if (
284
-		! give_logged_in_only( $form_id )
285
-		&& isset( $_POST['give-purchase-var'] )
284
+		! give_logged_in_only($form_id)
285
+		&& isset($_POST['give-purchase-var'])
286 286
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
287
-		&& empty( $_POST['give_user_login'] )
287
+		&& empty($_POST['give_user_login'])
288 288
 	) {
289
-		unset( $_POST['give-purchase-var'] );
289
+		unset($_POST['give-purchase-var']);
290 290
 	}
291 291
 
292
-	if ( is_user_logged_in() ) {
292
+	if (is_user_logged_in()) {
293 293
 		// Collect logged in user data
294 294
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
295
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
295
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
296 296
 		// Set new user registration as required
297 297
 		$valid_data['need_new_user'] = true;
298 298
 		// Validate new user data
299 299
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
300 300
 		// Check if login validation is needed
301
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
301
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
302 302
 		// Set user login as required
303 303
 		$valid_data['need_user_login'] = true;
304 304
 		// Validate users login info
@@ -323,41 +323,41 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_purchase_form_validate_gateway() {
325 325
 
326
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
327
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
328
-	$gateway = give_get_default_gateway( $form_id );
326
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
327
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
328
+	$gateway = give_get_default_gateway($form_id);
329 329
 
330 330
 	// Check if a gateway value is present
331
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
331
+	if ( ! empty($_REQUEST['give-gateway'])) {
332 332
 
333
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
333
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
334 334
 
335 335
 		// Is amount being donated in LIVE mode 0.00? If so, error:
336
-		if ( $amount == 0 && ! give_is_test_mode() ) {
336
+		if ($amount == 0 && ! give_is_test_mode()) {
337 337
 
338
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
338
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
339 339
 
340 340
 		} //Check for a minimum custom amount
341
-		elseif ( ! give_verify_minimum_price() ) {
341
+		elseif ( ! give_verify_minimum_price()) {
342 342
 			// translators: %s: minimum donation amount.
343 343
 			give_set_error(
344 344
 				'invalid_donation_minimum',
345 345
 				sprintf(
346 346
 				/* translators: %s: minimum donation amount */
347
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
348
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
347
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
348
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
349 349
 				)
350 350
 			);
351 351
 
352 352
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
353
-		elseif ( $amount == 0 && give_is_test_mode() ) {
353
+		elseif ($amount == 0 && give_is_test_mode()) {
354 354
 
355 355
 			$gateway = 'manual';
356 356
 
357 357
 		} //Check if this gateway is active.
358
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
358
+		elseif ( ! give_is_gateway_active($gateway)) {
359 359
 
360
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
360
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
361 361
 
362 362
 		}
363 363
 	}
@@ -375,23 +375,23 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_verify_minimum_price() {
377 377
 
378
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
379
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
380
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
381
-	$variable_prices = give_has_variable_prices( $form_id );
378
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
379
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
380
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
381
+	$variable_prices = give_has_variable_prices($form_id);
382 382
 
383
-	if ( $variable_prices && ! empty( $price_id ) ) {
383
+	if ($variable_prices && ! empty($price_id)) {
384 384
 
385
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
385
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
386 386
 
387
-		if ( $price_level_amount == $amount ) {
387
+		if ($price_level_amount == $amount) {
388 388
 			return true;
389 389
 		}
390 390
 	}
391 391
 
392
-	$minimum = give_get_form_minimum_price( $form_id );
392
+	$minimum = give_get_form_minimum_price($form_id);
393 393
 
394
-	if ( $minimum > $amount ) {
394
+	if ($minimum > $amount) {
395 395
 		return false;
396 396
 	}
397 397
 
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
  */
408 408
 function give_purchase_form_validate_agree_to_terms() {
409 409
 	// Validate agree to terms.
410
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
410
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
411 411
 		// User did not agree.
412
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) );
412
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give')));
413 413
 	}
414 414
 }
415 415
 
@@ -423,43 +423,43 @@  discard block
 block discarded – undo
423 423
  *
424 424
  * @return      array
425 425
  */
426
-function give_get_required_fields( $form_id ) {
426
+function give_get_required_fields($form_id) {
427 427
 
428
-	$payment_mode = give_get_chosen_gateway( $form_id );
428
+	$payment_mode = give_get_chosen_gateway($form_id);
429 429
 
430 430
 	$required_fields = array(
431 431
 		'give_email' => array(
432 432
 			'error_id'      => 'invalid_email',
433
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ),
433
+			'error_message' => esc_html__('Please enter a valid email address.', 'give'),
434 434
 		),
435 435
 		'give_first' => array(
436 436
 			'error_id'      => 'invalid_first_name',
437
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' ),
437
+			'error_message' => esc_html__('Please enter your first name.', 'give'),
438 438
 		),
439 439
 	);
440 440
 
441
-	$require_address = give_require_billing_address( $payment_mode );
441
+	$require_address = give_require_billing_address($payment_mode);
442 442
 
443
-	if ( $require_address ) {
444
-		$required_fields['card_address']    = array(
443
+	if ($require_address) {
444
+		$required_fields['card_address'] = array(
445 445
 			'error_id'      => 'invalid_card_address',
446
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ),
446
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give'),
447 447
 		);
448
-		$required_fields['card_zip']        = array(
448
+		$required_fields['card_zip'] = array(
449 449
 			'error_id'      => 'invalid_zip_code',
450
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ),
450
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give'),
451 451
 		);
452
-		$required_fields['card_city']       = array(
452
+		$required_fields['card_city'] = array(
453 453
 			'error_id'      => 'invalid_city',
454
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' ),
454
+			'error_message' => esc_html__('Please enter your billing city.', 'give'),
455 455
 		);
456 456
 		$required_fields['billing_country'] = array(
457 457
 			'error_id'      => 'invalid_country',
458
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' ),
458
+			'error_message' => esc_html__('Please select your billing country.', 'give'),
459 459
 		);
460
-		$required_fields['card_state']      = array(
460
+		$required_fields['card_state'] = array(
461 461
 			'error_id'      => 'invalid_state',
462
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ),
462
+			'error_message' => esc_html__('Please enter billing state / province.', 'give'),
463 463
 		);
464 464
 	}
465 465
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @since 1.7
470 470
 	 */
471
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
471
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
472 472
 
473 473
 	return $required_fields;
474 474
 
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
  *
484 484
  * @return mixed|void
485 485
  */
486
-function give_require_billing_address( $payment_mode ) {
486
+function give_require_billing_address($payment_mode) {
487 487
 
488 488
 	$return = false;
489 489
 
490
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
490
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
491 491
 		$return = true;
492 492
 	}
493 493
 
494 494
 	// Let payment gateways and other extensions determine if address fields should be required.
495
-	return apply_filters( 'give_require_billing_address', $return );
495
+	return apply_filters('give_require_billing_address', $return);
496 496
 
497 497
 }
498 498
 
@@ -506,42 +506,42 @@  discard block
 block discarded – undo
506 506
 function give_purchase_form_validate_logged_in_user() {
507 507
 	global $user_ID;
508 508
 
509
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
509
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
510 510
 
511 511
 	// Start empty array to collect valid user data.
512 512
 	$valid_user_data = array(
513 513
 		// Assume there will be errors.
514
-		'user_id' => - 1,
514
+		'user_id' => -1,
515 515
 	);
516 516
 
517 517
 	// Verify there is a user_ID.
518
-	if ( $user_ID > 0 ) {
518
+	if ($user_ID > 0) {
519 519
 		// Get the logged in user data.
520
-		$user_data = get_userdata( $user_ID );
520
+		$user_data = get_userdata($user_ID);
521 521
 
522 522
 		// Loop through required fields and show error messages.
523
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
524
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
525
-				give_set_error( $value['error_id'], $value['error_message'] );
523
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
524
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
525
+				give_set_error($value['error_id'], $value['error_message']);
526 526
 			}
527 527
 		}
528 528
 
529 529
 		// Verify data.
530
-		if ( $user_data ) {
530
+		if ($user_data) {
531 531
 			// Collected logged in user data.
532 532
 			$valid_user_data = array(
533 533
 				'user_id'    => $user_ID,
534
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
535
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
536
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
534
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
535
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
536
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
537 537
 			);
538 538
 
539
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
540
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
539
+			if ( ! is_email($valid_user_data['user_email'])) {
540
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
541 541
 			}
542 542
 		} else {
543 543
 			// Set invalid user error.
544
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
544
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
545 545
 		}
546 546
 	}
547 547
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	// Default user data.
561 561
 	$default_user_data = array(
562 562
 		'give-form-id'           => '',
563
-		'user_id'                => - 1, // Assume there will be errors.
563
+		'user_id'                => -1, // Assume there will be errors.
564 564
 		'user_first'             => '',
565 565
 		'user_last'              => '',
566 566
 		'give_user_login'        => false,
@@ -570,14 +570,14 @@  discard block
 block discarded – undo
570 570
 	);
571 571
 
572 572
 	// Get user data.
573
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
573
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
574 574
 	$registering_new_user = false;
575
-	$form_id              = absint( $user_data['give-form-id'] );
575
+	$form_id              = absint($user_data['give-form-id']);
576 576
 
577 577
 	// Start an empty array to collect valid user data.
578 578
 	$valid_user_data = array(
579 579
 		// Assume there will be errors.
580
-		'user_id'    => - 1,
580
+		'user_id'    => -1,
581 581
 
582 582
 		// Get first name.
583 583
 		'user_first' => $user_data['give_first'],
@@ -587,25 +587,25 @@  discard block
 block discarded – undo
587 587
 	);
588 588
 
589 589
 	// Loop through required fields and show error messages.
590
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
591
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
592
-			give_set_error( $value['error_id'], $value['error_message'] );
590
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
591
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
592
+			give_set_error($value['error_id'], $value['error_message']);
593 593
 		}
594 594
 	}
595 595
 
596 596
 	// Check if we have an username to register.
597
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
597
+	if (give_validate_username($user_data['give_user_login'])) {
598 598
 		$registering_new_user          = true;
599 599
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
600 600
 	}
601 601
 
602 602
 	// Check if we have an email to verify.
603
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
603
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
604 604
 		$valid_user_data['user_email'] = $user_data['give_email'];
605 605
 	}
606 606
 
607 607
 	// Check password.
608
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
608
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
609 609
 		// All is good to go.
610 610
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
611 611
 	}
@@ -625,36 +625,36 @@  discard block
 block discarded – undo
625 625
 	// Start an array to collect valid user data.
626 626
 	$valid_user_data = array(
627 627
 		// Assume there will be errors
628
-		'user_id' => - 1,
628
+		'user_id' => -1,
629 629
 	);
630 630
 
631 631
 	// Username.
632
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
633
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
632
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
633
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
634 634
 
635 635
 		return $valid_user_data;
636 636
 	}
637 637
 
638 638
 	// Get the user by login.
639
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
639
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
640 640
 
641 641
 	// Check if user exists.
642
-	if ( $user_data ) {
642
+	if ($user_data) {
643 643
 		// Get password.
644
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
644
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
645 645
 
646 646
 		// Check user_pass.
647
-		if ( $user_pass ) {
647
+		if ($user_pass) {
648 648
 			// Check if password is valid.
649
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
649
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
650 650
 				// Incorrect password.
651 651
 				give_set_error(
652 652
 					'password_incorrect',
653 653
 					sprintf(
654 654
 						'%1$s <a href="%2$s">%3$s</a>',
655
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
656
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
657
-						esc_html__( 'Reset Password', 'give' )
655
+						esc_html__('The password you entered is incorrect.', 'give'),
656
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
657
+						esc_html__('Reset Password', 'give')
658 658
 					)
659 659
 				);
660 660
 				// All is correct.
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
 			}
672 672
 		} else {
673 673
 			// Empty password.
674
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
674
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
675 675
 		}
676 676
 	} else {
677 677
 		// No username.
678
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
678
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
679 679
 	}
680 680
 
681 681
 	return $valid_user_data;
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
  */
691 691
 function give_purchase_form_validate_guest_user() {
692 692
 
693
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
693
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
694 694
 
695 695
 	// Start an array to collect valid user data.
696 696
 	$valid_user_data = array(
@@ -699,38 +699,38 @@  discard block
 block discarded – undo
699 699
 	);
700 700
 
701 701
 	// Show error message if user must be logged in.
702
-	if ( give_logged_in_only( $form_id ) ) {
703
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
702
+	if (give_logged_in_only($form_id)) {
703
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
704 704
 	}
705 705
 
706 706
 	// Get the guest email.
707
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
707
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
708 708
 
709 709
 	// Check email.
710
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
710
+	if ($guest_email && strlen($guest_email) > 0) {
711 711
 		// Validate email.
712
-		if ( ! is_email( $guest_email ) ) {
712
+		if ( ! is_email($guest_email)) {
713 713
 			// Invalid email.
714
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
714
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
715 715
 		} else {
716 716
 			// All is good to go.
717 717
 			$valid_user_data['user_email'] = $guest_email;
718 718
 
719 719
 			// Get user_id from donor if exist.
720
-			$donor = new Give_Customer( $guest_email );
721
-			if ( $donor->id && $donor->user_id ) {
720
+			$donor = new Give_Customer($guest_email);
721
+			if ($donor->id && $donor->user_id) {
722 722
 				$valid_user_data['user_id'] = $donor->user_id;
723 723
 			}
724 724
 		}
725 725
 	} else {
726 726
 		// No email.
727
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
727
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
728 728
 	}
729 729
 
730 730
 	// Loop through required fields and show error messages.
731
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
732
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
733
-			give_set_error( $value['error_id'], $value['error_message'] );
731
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
732
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
733
+			give_set_error($value['error_id'], $value['error_message']);
734 734
 		}
735 735
 	}
736 736
 
@@ -746,36 +746,36 @@  discard block
 block discarded – undo
746 746
  * @since   1.0
747 747
  * @return  integer
748 748
  */
749
-function give_register_and_login_new_user( $user_data = array() ) {
749
+function give_register_and_login_new_user($user_data = array()) {
750 750
 	// Verify the array.
751
-	if ( empty( $user_data ) ) {
752
-		return - 1;
751
+	if (empty($user_data)) {
752
+		return -1;
753 753
 	}
754 754
 
755
-	if ( give_get_errors() ) {
756
-		return - 1;
755
+	if (give_get_errors()) {
756
+		return -1;
757 757
 	}
758 758
 
759
-	$user_args = apply_filters( 'give_insert_user_args', array(
760
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
761
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
762
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
763
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
764
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
765
-		'user_registered' => date( 'Y-m-d H:i:s' ),
766
-		'role'            => get_option( 'default_role' ),
767
-	), $user_data );
759
+	$user_args = apply_filters('give_insert_user_args', array(
760
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
761
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
762
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
763
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
764
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
765
+		'user_registered' => date('Y-m-d H:i:s'),
766
+		'role'            => get_option('default_role'),
767
+	), $user_data);
768 768
 
769 769
 	// Insert new user.
770
-	$user_id = wp_insert_user( $user_args );
770
+	$user_id = wp_insert_user($user_args);
771 771
 
772 772
 	// Validate inserted user.
773
-	if ( is_wp_error( $user_id ) ) {
774
-		return - 1;
773
+	if (is_wp_error($user_id)) {
774
+		return -1;
775 775
 	}
776 776
 
777 777
 	// Allow themes and plugins to filter the user data.
778
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
778
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
779 779
 
780 780
 	/**
781 781
 	 * Fires after inserting user.
@@ -785,10 +785,10 @@  discard block
 block discarded – undo
785 785
 	 * @param int $user_id User id.
786 786
 	 * @param array $user_data Array containing user data.
787 787
 	 */
788
-	do_action( 'give_insert_user', $user_id, $user_data );
788
+	do_action('give_insert_user', $user_id, $user_data);
789 789
 
790 790
 	// Login new user.
791
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
791
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
792 792
 
793 793
 	// Return user id.
794 794
 	return $user_id;
@@ -803,27 +803,27 @@  discard block
 block discarded – undo
803 803
  * @since   1.0
804 804
  * @return  array
805 805
  */
806
-function give_get_purchase_form_user( $valid_data = array() ) {
806
+function give_get_purchase_form_user($valid_data = array()) {
807 807
 
808 808
 	// Initialize user.
809 809
 	$user    = false;
810
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
810
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
811 811
 
812
-	if ( $is_ajax ) {
812
+	if ($is_ajax) {
813 813
 		// Do not create or login the user during the ajax submission (check for errors only).
814 814
 		return true;
815
-	} elseif ( is_user_logged_in() ) {
815
+	} elseif (is_user_logged_in()) {
816 816
 		// Set the valid user as the logged in collected data.
817 817
 		$user = $valid_data['logged_in_user'];
818
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
818
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
819 819
 		// New user registration.
820
-		if ( $valid_data['need_new_user'] === true ) {
820
+		if ($valid_data['need_new_user'] === true) {
821 821
 			// Set user.
822 822
 			$user = $valid_data['new_user_data'];
823 823
 			// Register and login new user.
824
-			$user['user_id'] = give_register_and_login_new_user( $user );
824
+			$user['user_id'] = give_register_and_login_new_user($user);
825 825
 			// User login
826
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
826
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
827 827
 
828 828
 			/*
829 829
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -836,48 +836,48 @@  discard block
 block discarded – undo
836 836
 			// Set user.
837 837
 			$user = $valid_data['login_user_data'];
838 838
 			// Login user.
839
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
839
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
840 840
 		}
841 841
 	}
842 842
 
843 843
 	// Check guest checkout.
844
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
844
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
845 845
 		// Set user
846 846
 		$user = $valid_data['guest_user_data'];
847 847
 	}
848 848
 
849 849
 	// Verify we have an user.
850
-	if ( false === $user || empty( $user ) ) {
850
+	if (false === $user || empty($user)) {
851 851
 		// Return false.
852 852
 		return false;
853 853
 	}
854 854
 
855 855
 	// Get user first name.
856
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
857
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
856
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
857
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
858 858
 	}
859 859
 
860 860
 	// Get user last name.
861
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
862
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
861
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
862
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
863 863
 	}
864 864
 
865 865
 	// Get the user's billing address details.
866 866
 	$user['address']            = array();
867
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
868
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
869
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
870
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
871
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
872
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
873
-
874
-	if ( empty( $user['address']['country'] ) ) {
867
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
868
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
869
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
870
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
871
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
872
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
873
+
874
+	if (empty($user['address']['country'])) {
875 875
 		$user['address'] = false;
876 876
 	} // Country will always be set if address fields are present.
877 877
 
878
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
878
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
879 879
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases.
880
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
880
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
881 881
 	}
882 882
 
883 883
 	// Return valid user.
@@ -896,16 +896,16 @@  discard block
 block discarded – undo
896 896
 	$card_data = give_get_purchase_cc_info();
897 897
 
898 898
 	// Validate the card zip.
899
-	if ( ! empty( $card_data['card_zip'] ) ) {
900
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
901
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
899
+	if ( ! empty($card_data['card_zip'])) {
900
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
901
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
902 902
 		}
903 903
 	}
904 904
 
905 905
 	// Ensure no spaces.
906
-	if ( ! empty( $card_data['card_number'] ) ) {
907
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
908
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
906
+	if ( ! empty($card_data['card_number'])) {
907
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
908
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
909 909
 	}
910 910
 
911 911
 	// This should validate card numbers at some point too.
@@ -921,17 +921,17 @@  discard block
 block discarded – undo
921 921
  */
922 922
 function give_get_purchase_cc_info() {
923 923
 	$cc_info                   = array();
924
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
925
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
926
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
927
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
928
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
929
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
930
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
931
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
932
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
933
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
934
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
924
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
925
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
926
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
927
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
928
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
929
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
930
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
931
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
932
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
933
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
934
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
935 935
 
936 936
 	// Return cc info
937 937
 	return $cc_info;
@@ -947,14 +947,14 @@  discard block
 block discarded – undo
947 947
  *
948 948
  * @return bool|mixed|void
949 949
  */
950
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
950
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
951 951
 	$ret = false;
952 952
 
953
-	if ( empty( $zip ) || empty( $country_code ) ) {
953
+	if (empty($zip) || empty($country_code)) {
954 954
 		return $ret;
955 955
 	}
956 956
 
957
-	$country_code = strtoupper( $country_code );
957
+	$country_code = strtoupper($country_code);
958 958
 
959 959
 	$zip_regex = array(
960 960
 		'AD' => 'AD\d{3}',
@@ -1114,11 +1114,11 @@  discard block
 block discarded – undo
1114 1114
 		'ZM' => '\d{5}',
1115 1115
 	);
1116 1116
 
1117
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1117
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1118 1118
 		$ret = true;
1119 1119
 	}
1120 1120
 
1121
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1121
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1122 1122
 }
1123 1123
 
1124 1124
 
@@ -1132,36 +1132,36 @@  discard block
 block discarded – undo
1132 1132
  *
1133 1133
  * @return bool
1134 1134
  */
1135
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1135
+function give_validate_multi_donation_form_level($valid_data, $data) {
1136 1136
 	/* @var Give_Donate_Form $form */
1137
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1137
+	$form = new Give_Donate_Form($data['give-form-id']);
1138 1138
 
1139 1139
 	$donation_level_matched = false;
1140 1140
 
1141
-	if ( $form->is_multi_type_donation_form() ) {
1141
+	if ($form->is_multi_type_donation_form()) {
1142 1142
 
1143 1143
 		// Bailout.
1144
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1144
+		if ( ! ($variable_prices = $form->get_prices())) {
1145 1145
 			return false;
1146 1146
 		}
1147 1147
 
1148 1148
 		// Sanitize donation amount.
1149
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1149
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1150 1150
 
1151 1151
 		// Get number of decimals.
1152 1152
 		$default_decimals = give_get_price_decimals();
1153 1153
 
1154
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1154
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1155 1155
 			return true;
1156 1156
 		}
1157 1157
 
1158 1158
 		// Find correct donation level from all donation levels.
1159
-		foreach ( $variable_prices as $variable_price ) {
1159
+		foreach ($variable_prices as $variable_price) {
1160 1160
 			// Sanitize level amount.
1161
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1161
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1162 1162
 
1163 1163
 			// Set first match donation level ID.
1164
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1164
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1165 1165
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1166 1166
 				$donation_level_matched = true;
1167 1167
 				break;
@@ -1172,19 +1172,19 @@  discard block
 block discarded – undo
1172 1172
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1173 1173
 		if (
1174 1174
 			! $donation_level_matched
1175
-			&& ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1175
+			&& (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true)))
1176 1176
 		) {
1177 1177
 			// Sanitize custom minimum amount.
1178
-			$custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1178
+			$custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1179 1179
 
1180
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1180
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1181 1181
 				$_POST['give-price-id'] = 'custom';
1182 1182
 				$donation_level_matched = true;
1183 1183
 			}
1184 1184
 		}
1185 1185
 	}
1186 1186
 
1187
-	return ( $donation_level_matched ? true : false );
1187
+	return ($donation_level_matched ? true : false);
1188 1188
 }
1189 1189
 
1190
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1190
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.