Completed
Pull Request — master (#986)
by Rami
20:36
created
includes/emails/functions.php 1 patch
Spacing   +97 added lines, -97 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,50 +26,50 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
37 37
 	 *
38 38
 	 * @since 1.7
39 39
 	 */
40
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
40
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
41 41
 
42
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
42
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
43 43
 
44 44
 	/**
45 45
 	 * Filters the from email.
46 46
 	 *
47 47
 	 * @since 1.7
48 48
 	 */
49
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
49
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
50 50
 
51
-	$to_email = give_get_payment_user_email( $payment_id );
51
+	$to_email = give_get_payment_user_email($payment_id);
52 52
 
53
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
54
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
55
-	$subject = give_do_email_tags( $subject, $payment_id );
53
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
54
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
55
+	$subject = give_do_email_tags($subject, $payment_id);
56 56
 
57
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
58
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
57
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
58
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
59 59
 
60 60
 	$emails = Give()->emails;
61 61
 
62
-	$emails->__set( 'from_name', $from_name );
63
-	$emails->__set( 'from_email', $from_email );
64
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
62
+	$emails->__set('from_name', $from_name);
63
+	$emails->__set('from_email', $from_email);
64
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
65 65
 
66 66
 
67
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
68
-	$emails->__set( 'headers', $headers );
67
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
68
+	$emails->__set('headers', $headers);
69 69
 
70
-	$emails->send( $to_email, $subject, $message, $attachments );
70
+	$emails->send($to_email, $subject, $message, $attachments);
71 71
 
72
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
72
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
73 73
 		/**
74 74
 		 * Fires in the email donation receipt.
75 75
 		 *
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		 * @param int   $payment_id   Payment id.
81 81
 		 * @param mixed $payment_data Payment meta data.
82 82
 		 */
83
-		do_action( 'give_admin_sale_notice', $payment_id, $payment_data );
83
+		do_action('give_admin_sale_notice', $payment_id, $payment_data);
84 84
 	}
85 85
 }
86 86
 
@@ -93,41 +93,41 @@  discard block
 block discarded – undo
93 93
  */
94 94
 function give_email_test_donation_receipt() {
95 95
 
96
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
96
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
97 97
 
98 98
 	/**
99 99
 	 * Filters the from name.
100 100
 	 *
101 101
 	 * @since 1.7
102 102
 	 */
103
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
103
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
104 104
 
105
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
105
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
106 106
 
107 107
 	/**
108 108
 	 * Filters the from email.
109 109
 	 *
110 110
 	 * @since 1.7
111 111
 	 */
112
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
112
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
113 113
 
114
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
115
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
116
-	$subject = give_do_email_tags( $subject, 0 );
114
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
115
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
116
+	$subject = give_do_email_tags($subject, 0);
117 117
 
118
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
118
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
119 119
 
120
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
120
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
121 121
 
122 122
 	$emails = Give()->emails;
123
-	$emails->__set( 'from_name', $from_name );
124
-	$emails->__set( 'from_email', $from_email );
125
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
123
+	$emails->__set('from_name', $from_name);
124
+	$emails->__set('from_email', $from_email);
125
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
126 126
 
127
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
128
-	$emails->__set( 'headers', $headers );
127
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
128
+	$emails->__set('headers', $headers);
129 129
 
130
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
130
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
131 131
 
132 132
 }
133 133
 
@@ -141,62 +141,62 @@  discard block
 block discarded – undo
141 141
  *
142 142
  * @return void
143 143
  */
144
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
144
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
145 145
 
146
-	$payment_id = absint( $payment_id );
146
+	$payment_id = absint($payment_id);
147 147
 
148
-	if ( empty( $payment_id ) ) {
148
+	if (empty($payment_id)) {
149 149
 		return;
150 150
 	}
151 151
 
152
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
152
+	if ( ! give_get_payment_by('id', $payment_id)) {
153 153
 		return;
154 154
 	}
155 155
 
156
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
156
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
157 157
 
158 158
 	/**
159 159
 	 * Filters the from name.
160 160
 	 *
161 161
 	 * @since 1.7
162 162
 	 */
163
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
163
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
164 164
 
165
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
165
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
166 166
 
167 167
 	/**
168 168
 	 * Filters the from email.
169 169
 	 *
170 170
 	 * @since 1.7
171 171
 	 */
172
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
172
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
173 173
 
174 174
 	/* translators: %s: payment id */
175
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
176
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
177
-	$subject = give_do_email_tags( $subject, $payment_id );
175
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
176
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
177
+	$subject = give_do_email_tags($subject, $payment_id);
178 178
 
179
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
180
-	$headers .= "Reply-To: " . $from_email . "\r\n";
179
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
180
+	$headers .= "Reply-To: ".$from_email."\r\n";
181 181
 	//$headers  .= "MIME-Version: 1.0\r\n";
182 182
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
183
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
183
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
184 184
 
185
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
185
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
186 186
 
187
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
187
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
188 188
 
189 189
 	$emails = Give()->emails;
190
-	$emails->__set( 'from_name', $from_name );
191
-	$emails->__set( 'from_email', $from_email );
192
-	$emails->__set( 'headers', $headers );
193
-	$emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) );
190
+	$emails->__set('from_name', $from_name);
191
+	$emails->__set('from_email', $from_email);
192
+	$emails->__set('headers', $headers);
193
+	$emails->__set('heading', esc_html__('New Donation!', 'give'));
194 194
 
195
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
195
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
196 196
 
197 197
 }
198 198
 
199
-add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 );
199
+add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2);
200 200
 
201 201
 /**
202 202
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 
209 209
 	$email_option = give_get_option('admin_notice_emails');
210 210
 
211
-	$emails = !empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
212
-	$emails = array_map( 'trim', explode( "\n", $emails ) );
211
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
212
+	$emails = array_map('trim', explode("\n", $emails));
213 213
 
214
-	return apply_filters( 'give_admin_notice_emails', $emails );
214
+	return apply_filters('give_admin_notice_emails', $emails);
215 215
 }
216 216
 
217 217
 /**
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
  *
224 224
  * @return mixed
225 225
  */
226
-function give_admin_notices_disabled( $payment_id = 0 ) {
226
+function give_admin_notices_disabled($payment_id = 0) {
227 227
 
228
-	$retval = give_get_option( 'disable_admin_notices' );
228
+	$retval = give_get_option('disable_admin_notices');
229 229
 
230
-	return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id );
230
+	return apply_filters('give_admin_notices_disabled', $retval, $payment_id);
231 231
 }
232 232
 
233 233
 /**
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
  */
241 241
 function give_get_default_donation_notification_email() {
242 242
 
243
-	$default_email_body  = esc_html__( 'Hi there,', 'give' ) . "\n\n";
244
-	$default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
245
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
246
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
247
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n";
248
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
249
-	$default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n";
250
-	$default_email_body .= '{sitename}' . "\n";
243
+	$default_email_body  = esc_html__('Hi there,', 'give')."\n\n";
244
+	$default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
245
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n";
246
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
247
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n";
248
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
249
+	$default_email_body .= esc_html__('Thank you,', 'give')."\n\n";
250
+	$default_email_body .= '{sitename}'."\n";
251 251
 
252
-	$custom_message = give_get_option( 'donation_notification' );
253
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
252
+	$custom_message = give_get_option('donation_notification');
253
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
254 254
 
255
-	return apply_filters( 'give_default_donation_notification_email', $message );
255
+	return apply_filters('give_default_donation_notification_email', $message);
256 256
 }
257 257
 
258 258
 
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
  */
267 267
 function give_get_default_donation_receipt_email() {
268 268
 
269
-	$default_email_body  = esc_html__( 'Dear', 'give' ) . " {name},\n\n";
270
-	$default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
271
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
272
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
273
-	$default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
274
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n";
275
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
276
-	$default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
277
-	$default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
278
-	$default_email_body .= '{receipt_link}' . "\n\n";
269
+	$default_email_body  = esc_html__('Dear', 'give')." {name},\n\n";
270
+	$default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
271
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n";
272
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
273
+	$default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n";
274
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n";
275
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
276
+	$default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
277
+	$default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
278
+	$default_email_body .= '{receipt_link}'."\n\n";
279 279
 	$default_email_body .= "\n\n";
280
-	$default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n";
281
-	$default_email_body .= '{sitename}' . "\n";
280
+	$default_email_body .= esc_html__('Sincerely,', 'give')."\n";
281
+	$default_email_body .= '{sitename}'."\n";
282 282
 
283
-	$custom_message = give_get_option( 'donation_receipt' );
283
+	$custom_message = give_get_option('donation_receipt');
284 284
 
285
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
285
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
286 286
 
287
-	return apply_filters( 'give_default_donation_receipt_email', $message );
287
+	return apply_filters('give_default_donation_receipt_email', $message);
288 288
 }
289 289
 
290 290
 /**
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @return array $email_names
298 298
  */
299
-function give_get_email_names( $user_info ) {
299
+function give_get_email_names($user_info) {
300 300
 	$email_names = array();
301
-	$user_info   = maybe_unserialize( $user_info );
301
+	$user_info   = maybe_unserialize($user_info);
302 302
 
303 303
 	$email_names['fullname'] = '';
304
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
305
-		$user_data               = get_userdata( $user_info['id'] );
304
+	if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
305
+		$user_data               = get_userdata($user_info['id']);
306 306
 		$email_names['name']     = $user_info['first_name'];
307
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
307
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
308 308
 		$email_names['username'] = $user_data->user_login;
309
-	} elseif ( isset( $user_info['first_name'] ) ) {
309
+	} elseif (isset($user_info['first_name'])) {
310 310
 		$email_names['name']     = $user_info['first_name'];
311
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
311
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
312 312
 		$email_names['username'] = $user_info['first_name'];
313 313
 	} else {
314 314
 		$email_names['name']     = $user_info['email'];
Please login to merge, or discard this patch.
includes/forms/widget.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-defined( 'ABSPATH' ) or exit;
13
+defined('ABSPATH') or exit;
14 14
 
15 15
 /**
16 16
  * Give Form widget
17 17
  *
18 18
  * @since 1.0
19 19
  */
20
-class Give_Forms_Widget extends WP_Widget{
20
+class Give_Forms_Widget extends WP_Widget {
21 21
 	/**
22 22
 	 * The widget class name
23 23
 	 *
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * Instantiate the class
30 30
 	 */
31
-	public function __construct(){
32
-		$this->self = get_class( $this );
31
+	public function __construct() {
32
+		$this->self = get_class($this);
33 33
 
34 34
 		parent::__construct(
35
-			strtolower( $this->self ),
36
-			esc_html__( 'Give - Donation Form', 'give' ),
35
+			strtolower($this->self),
36
+			esc_html__('Give - Donation Form', 'give'),
37 37
 			array(
38
-				'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' )
38
+				'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give')
39 39
 			)
40 40
 		);
41 41
 
42
-		add_action( 'widgets_init',          array( $this, 'widget_init' ) );
43
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) );
42
+		add_action('widgets_init', array($this, 'widget_init'));
43
+		add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts'));
44 44
 	}
45 45
 
46 46
 	/**
@@ -50,23 +50,23 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return void
52 52
 	 */
53
-	public function admin_widget_scripts( $hook ){
53
+	public function admin_widget_scripts($hook) {
54 54
 		// Directories of assets
55
-		$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
56
-		$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
57
-		$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
55
+		$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
56
+		$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
57
+		$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
58 58
 
59 59
 		// Use minified libraries if SCRIPT_DEBUG is turned off
60
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
60
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
61 61
 
62 62
 		// Widget Script
63
-		if ( $hook == 'widgets.php' ) {
63
+		if ($hook == 'widgets.php') {
64 64
 
65
-			wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' );
65
+			wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css');
66 66
 
67
-			wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
67
+			wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION);
68 68
 
69
-			wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
69
+			wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
70 70
 		}
71 71
 	}
72 72
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	 *                        before_widget, and after_widget.
78 78
 	 * @param array $instance The settings for the particular instance of the widget.
79 79
 	 */
80
-	public function widget( $args, $instance ){
81
-		$title = !empty( $instance['title'] ) ? $instance['title'] : '';
82
-		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
80
+	public function widget($args, $instance) {
81
+		$title = ! empty($instance['title']) ? $instance['title'] : '';
82
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
83 83
 
84 84
 		echo $args['before_widget'];
85 85
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 		 *
89 89
 		 * @since 1.0
90 90
 		 */
91
-		do_action( 'give_before_forms_widget' );
91
+		do_action('give_before_forms_widget');
92 92
 
93
-		echo $title ? $args['before_title'] . $title . $args['after_title'] : '';
93
+		echo $title ? $args['before_title'].$title.$args['after_title'] : '';
94 94
 
95
-		give_get_donation_form( $instance );
95
+		give_get_donation_form($instance);
96 96
 
97 97
 		echo $args['after_widget'];
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		 *
102 102
 		 * @since 1.0
103 103
 		 */
104
-		do_action( 'give_after_forms_widget' );
104
+		do_action('give_after_forms_widget');
105 105
 	}
106 106
 
107 107
 	/**
@@ -111,61 +111,61 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return string
113 113
 	 */
114
-	public function form( $instance ){
114
+	public function form($instance) {
115 115
 		$defaults = array(
116 116
 			'title'        => '',
117 117
 			'id'           => '',
118 118
 			'float_labels' => '',
119 119
 		);
120 120
 
121
-		$instance = wp_parse_args( (array) $instance, $defaults );
121
+		$instance = wp_parse_args((array) $instance, $defaults);
122 122
 
123 123
 		// Query Give Forms
124 124
 		$args = array(
125 125
 			'post_type'      => 'give_forms',
126
-			'posts_per_page' => - 1,
126
+			'posts_per_page' => -1,
127 127
 			'post_status'    => 'publish',
128 128
 		);
129 129
 
130
-		$give_forms = get_posts( $args );
130
+		$give_forms = get_posts($args);
131 131
 
132 132
 		// Widget: Title
133 133
 
134 134
 		?><p>
135
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label>
136
-			<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /><br>
137
-			<small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small>
135
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label>
136
+			<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" /><br>
137
+			<small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small>
138 138
 		</p><?php
139 139
 
140 140
 		// Widget: Give Form
141 141
 
142 142
 		?><p>
143
-			<label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php
143
+			<label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php
144 144
 				printf(
145 145
 					/* translators: %s: form singular label */
146
-					esc_html__( 'Give %s:', 'give' ),
146
+					esc_html__('Give %s:', 'give'),
147 147
 					give_get_forms_label_singular()
148 148
 				);
149 149
 			?></label>
150
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>">
151
-				<option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option>
152
-				<?php foreach ( $give_forms as $give_form ) { ?>
153
-					<option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option>
150
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>">
151
+				<option value="current"><?php esc_html_e('- Select -', 'give'); ?></option>
152
+				<?php foreach ($give_forms as $give_form) { ?>
153
+					<option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option>
154 154
 				<?php } ?>
155 155
 			</select><br>
156
-			<small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small>
156
+			<small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small>
157 157
 		</p><?php
158 158
 
159 159
 		// Widget: Floating Labels
160 160
 
161 161
 		?><p>
162
-			<label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels:', 'give' ); ?></label>
163
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>">
164
-				<option value="" <?php selected( esc_attr( $instance['float_labels'] ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option>
165
-				<option value="enabled" <?php selected( esc_attr( $instance['float_labels'] ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option>
166
-				<option value="disabled" <?php selected( esc_attr( $instance['float_labels'] ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option>
162
+			<label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels:', 'give'); ?></label>
163
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>">
164
+				<option value="" <?php selected(esc_attr($instance['float_labels']), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option>
165
+				<option value="enabled" <?php selected(esc_attr($instance['float_labels']), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option>
166
+				<option value="disabled" <?php selected(esc_attr($instance['float_labels']), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option>
167 167
 			</select><br>
168
-			<small><?php esc_html_e( 'Override the default floating labels setting for this form.', 'give' ); ?></small>
168
+			<small><?php esc_html_e('Override the default floating labels setting for this form.', 'give'); ?></small>
169 169
 		</p><?php
170 170
 	}
171 171
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return void
176 176
 	 */
177
-	function widget_init(){
178
-		register_widget( $this->self );
177
+	function widget_init() {
178
+		register_widget($this->self);
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return array
188 188
 	 */
189
-	public function update( $new_instance, $old_instance ){
189
+	public function update($new_instance, $old_instance) {
190 190
 		$this->flush_widget_cache();
191 191
 
192 192
 		return $new_instance;
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return void
199 199
 	 */
200
-	public function flush_widget_cache(){
201
-		wp_cache_delete( $this->self, 'widget' );
200
+	public function flush_widget_cache() {
201
+		wp_cache_delete($this->self, 'widget');
202 202
 	}
203 203
 }
204 204
 
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 
39 39
 		} else {
40 40
 
41
-			if ( $airplane->check_status() == 'on' ) {
41
+			if ($airplane->check_status() == 'on') {
42 42
 				return true;
43 43
 			}
44 44
 		}
45 45
 	}
46 46
 
47
-	add_filter( 'block_local_requests', '__return_false' );
47
+	add_filter('block_local_requests', '__return_false');
48 48
 
49
-	if ( get_transient( '_give_ajax_works' ) ) {
49
+	if (get_transient('_give_ajax_works')) {
50 50
 		return true;
51 51
 	}
52 52
 
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
 		)
59 59
 	);
60 60
 
61
-	$ajax  = wp_remote_post( give_get_ajax_url(), $params );
61
+	$ajax  = wp_remote_post(give_get_ajax_url(), $params);
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 
86 86
 	}
87 87
 
88
-	if ( $works ) {
89
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
88
+	if ($works) {
89
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
90 90
 	}
91 91
 
92 92
 	return $works;
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
  * @return string
102 102
  */
103 103
 function give_get_ajax_url() {
104
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
104
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
105 105
 
106 106
 	$current_url = give_get_current_page_url();
107
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
107
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
108 108
 
109
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
110
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
109
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
110
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
111 111
 	}
112 112
 
113
-	return apply_filters( 'give_ajax_url', $ajax_url );
113
+	return apply_filters('give_ajax_url', $ajax_url);
114 114
 }
115 115
 
116 116
 /**
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.7
128 128
 	 */
129
-	do_action( 'give_donation_form_login_fields' );
129
+	do_action('give_donation_form_login_fields');
130 130
 
131 131
 	give_die();
132 132
 }
133 133
 
134
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
134
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
135 135
 
136 136
 /**
137 137
  * Load Checkout Fields
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  * @return void
142 142
  */
143 143
 function give_load_checkout_fields() {
144
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
144
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
145 145
 
146 146
 	ob_start();
147 147
 
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 1.7
152 152
 	 */
153
-	do_action( 'give_donation_form_register_login_fields', $form_id );
153
+	do_action('give_donation_form_register_login_fields', $form_id);
154 154
 
155 155
 	$fields = ob_get_clean();
156 156
 
157
-	wp_send_json( array(
158
-		'fields' => wp_json_encode( $fields ),
159
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
160
-	) );
157
+	wp_send_json(array(
158
+		'fields' => wp_json_encode($fields),
159
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
160
+	));
161 161
 }
162 162
 
163
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
164
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
163
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
164
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
165 165
 
166 166
 /**
167 167
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
  * @return void
172 172
  */
173 173
 function give_ajax_get_form_title() {
174
-	if ( isset( $_POST['form_id'] ) ) {
175
-		$title = get_the_title( $_POST['form_id'] );
176
-		if ( $title ) {
174
+	if (isset($_POST['form_id'])) {
175
+		$title = get_the_title($_POST['form_id']);
176
+		if ($title) {
177 177
 			echo $title;
178 178
 		} else {
179 179
 			echo 'fail';
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	give_die();
183 183
 }
184 184
 
185
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
186
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
185
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
186
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
187 187
 
188 188
 /**
189 189
  * Retrieve a states drop down
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function give_ajax_get_states_field() {
196 196
 
197
-	if ( empty( $_POST['country'] ) ) {
197
+	if (empty($_POST['country'])) {
198 198
 		$_POST['country'] = give_get_country();
199 199
 	}
200
-	$states = give_get_states( $_POST['country'] );
200
+	$states = give_get_states($_POST['country']);
201 201
 
202
-	if ( ! empty( $states ) ) {
202
+	if ( ! empty($states)) {
203 203
 
204 204
 		$args = array(
205 205
 			'name'             => $_POST['field_name'],
206 206
 			'id'               => $_POST['field_name'],
207
-			'class'            => $_POST['field_name'] . '  give-select',
208
-			'options'          => give_get_states( $_POST['country'] ),
207
+			'class'            => $_POST['field_name'].'  give-select',
208
+			'options'          => give_get_states($_POST['country']),
209 209
 			'show_option_all'  => false,
210 210
 			'show_option_none' => false
211 211
 		);
212 212
 
213
-		$response = Give()->html->select( $args );
213
+		$response = Give()->html->select($args);
214 214
 
215 215
 	} else {
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	give_die();
223 223
 }
224 224
 
225
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
226
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
225
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
226
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
227 227
 
228 228
 /**
229 229
  * Retrieve a states drop down
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 function give_ajax_form_search() {
236 236
 	global $wpdb;
237 237
 
238
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
239 239
 	$results = array();
240
-	if ( current_user_can( 'edit_give_forms' ) ) {
241
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
240
+	if (current_user_can('edit_give_forms')) {
241
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
242 242
 	} else {
243
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
243
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
244 244
 	}
245 245
 
246
-	if ( $items ) {
246
+	if ($items) {
247 247
 
248
-		foreach ( $items as $item ) {
248
+		foreach ($items as $item) {
249 249
 
250 250
 			$results[] = array(
251 251
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => esc_html__( 'No results found', 'give' )
260
+			'name' => esc_html__('No results found', 'give')
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,21 +280,21 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . '(' . $donor->email . ')'
297
+				'name' => $donor->name.'('.$donor->email.')'
298 298
 			);
299 299
 		}
300 300
 
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
 
303 303
 		$donors[] = array(
304 304
 			'id'   => 0,
305
-			'name' => esc_html__( 'No results found', 'give' )
305
+			'name' => esc_html__('No results found', 'give')
306 306
 		);
307 307
 
308 308
 	}
309 309
 
310
-	echo json_encode( $results );
310
+	echo json_encode($results);
311 311
 
312 312
 	give_die();
313 313
 }
314 314
 
315
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
315
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
316 316
 
317 317
 
318 318
 /**
@@ -324,42 +324,42 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function give_ajax_search_users() {
326 326
 
327
-	if ( current_user_can( 'manage_give_settings' ) ) {
327
+	if (current_user_can('manage_give_settings')) {
328 328
 
329
-		$search_query = trim( $_POST['user_name'] );
330
-		$exclude      = trim( $_POST['exclude'] );
329
+		$search_query = trim($_POST['user_name']);
330
+		$exclude      = trim($_POST['exclude']);
331 331
 
332 332
 		$get_users_args = array(
333 333
 			'number' => 9999,
334
-			'search' => $search_query . '*'
334
+			'search' => $search_query.'*'
335 335
 		);
336 336
 
337
-		if ( ! empty( $exclude ) ) {
338
-			$exclude_array             = explode( ',', $exclude );
337
+		if ( ! empty($exclude)) {
338
+			$exclude_array             = explode(',', $exclude);
339 339
 			$get_users_args['exclude'] = $exclude_array;
340 340
 		}
341 341
 
342
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
342
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
343 343
 
344
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
344
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
345 345
 
346 346
 		$user_list = '<ul>';
347
-		if ( $found_users ) {
348
-			foreach ( $found_users as $user ) {
349
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>';
347
+		if ($found_users) {
348
+			foreach ($found_users as $user) {
349
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>';
350 350
 			}
351 351
 		} else {
352
-			$user_list .= '<li>' . esc_html__( 'No users found', 'give' ) . '</li>';
352
+			$user_list .= '<li>'.esc_html__('No users found', 'give').'</li>';
353 353
 		}
354 354
 		$user_list .= '</ul>';
355 355
 
356
-		echo json_encode( array( 'results' => $user_list ) );
356
+		echo json_encode(array('results' => $user_list));
357 357
 
358 358
 	}
359 359
 	die();
360 360
 }
361 361
 
362
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
362
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
363 363
 
364 364
 
365 365
 /**
@@ -371,32 +371,32 @@  discard block
 block discarded – undo
371 371
  */
372 372
 function give_check_for_form_price_variations() {
373 373
 
374
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
375
-		die( '-1' );
374
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
375
+		die('-1');
376 376
 	}
377 377
 
378
-	$form_id = intval( $_POST['form_id'] );
379
-	$form    = get_post( $form_id );
378
+	$form_id = intval($_POST['form_id']);
379
+	$form    = get_post($form_id);
380 380
 
381
-	if ( 'give_forms' != $form->post_type ) {
382
-		die( '-2' );
381
+	if ('give_forms' != $form->post_type) {
382
+		die('-2');
383 383
 	}
384 384
 
385
-	if ( give_has_variable_prices( $form_id ) ) {
386
-		$variable_prices = give_get_variable_prices( $form_id );
385
+	if (give_has_variable_prices($form_id)) {
386
+		$variable_prices = give_get_variable_prices($form_id);
387 387
 
388
-		if ( $variable_prices ) {
388
+		if ($variable_prices) {
389 389
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
390 390
 
391
-			if ( isset( $_POST['all_prices'] ) ) {
392
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
391
+			if (isset($_POST['all_prices'])) {
392
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
393 393
 			}
394 394
 
395
-			foreach ( $variable_prices as $key => $price ) {
395
+			foreach ($variable_prices as $key => $price) {
396 396
 
397
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
397
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
398 398
 				
399
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
399
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
400 400
 			}
401 401
 			$ajax_response .= '</select>';
402 402
 			echo $ajax_response;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	give_die();
408 408
 }
409 409
 
410
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
410
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
411 411
 
412 412
 
413 413
 /**
@@ -418,30 +418,30 @@  discard block
 block discarded – undo
418 418
  * @return void
419 419
  */
420 420
 function give_check_for_form_price_variations_html() {
421
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
421
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
422 422
 		wp_die();
423 423
 	}
424 424
 
425
-	$form_id = intval( $_POST['form_id'] );
426
-	$payment_id = intval( $_POST['payment_id'] );
427
-	$form    = get_post( $form_id );
425
+	$form_id = intval($_POST['form_id']);
426
+	$payment_id = intval($_POST['payment_id']);
427
+	$form    = get_post($form_id);
428 428
 
429
-	if ( 'give_forms' != $form->post_type ) {
429
+	if ('give_forms' != $form->post_type) {
430 430
 		wp_die();
431 431
 	}
432 432
 
433
-    if ( ! give_has_variable_prices( $form_id ) ) {
434
-        esc_html_e( 'n/a', 'give' );
433
+    if ( ! give_has_variable_prices($form_id)) {
434
+        esc_html_e('n/a', 'give');
435 435
     } else {
436 436
         // Payment object.
437
-        $payment = new Give_Payment( $payment_id );
437
+        $payment = new Give_Payment($payment_id);
438 438
 
439 439
         // Payment meta.
440 440
         $payment_meta = $payment->get_meta();
441 441
 
442 442
 
443 443
         // Variable price dropdown options.
444
-        $variable_price_dropdown_option =  array(
444
+        $variable_price_dropdown_option = array(
445 445
             'id'                => $form_id,
446 446
             'name'              => 'give-variable-price',
447 447
             'chosen'            => true,
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
         );
451 451
 
452 452
         // Render variable prices select tag html.
453
-        give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
453
+        give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
454 454
     }
455 455
 
456 456
     give_die();
457 457
 }
458 458
 
459
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
459
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/process-purchase.php 1 patch
Spacing   +250 added lines, -250 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_purchase' );
33
+	do_action('give_pre_process_purchase');
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_checkout_errors' );
67
+			do_action('give_ajax_checkout_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_purchase_form' );
164
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
163
+add_action('give_purchase', 'give_process_purchase_form');
164
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
165
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
166 166
 
167 167
 /**
168 168
  * Process the checkout login form
@@ -173,37 +173,37 @@  discard block
 block discarded – undo
173 173
  */
174 174
 function give_process_form_login() {
175 175
 
176
-	$is_ajax = isset( $_POST['give_ajax'] );
176
+	$is_ajax = isset($_POST['give_ajax']);
177 177
 
178 178
 	$user_data = give_purchase_form_validate_user_login();
179 179
 
180
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
181
-		if ( $is_ajax ) {
180
+	if (give_get_errors() || $user_data['user_id'] < 1) {
181
+		if ($is_ajax) {
182 182
 			/**
183 183
 			 * Fires when AJAX sends back errors from the donation form.
184 184
 			 *
185 185
 			 * @since 1.0
186 186
 			 */
187
-			do_action( 'give_ajax_checkout_errors' );
187
+			do_action('give_ajax_checkout_errors');
188 188
 			give_die();
189 189
 		} else {
190
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
190
+			wp_redirect($_SERVER['HTTP_REFERER']);
191 191
 			exit;
192 192
 		}
193 193
 	}
194 194
 
195
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
195
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
196 196
 
197
-	if ( $is_ajax ) {
197
+	if ($is_ajax) {
198 198
 		echo 'success';
199 199
 		give_die();
200 200
 	} else {
201
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
201
+		wp_redirect($_SERVER['HTTP_REFERER']);
202 202
 	}
203 203
 }
204 204
 
205
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
206
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
205
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
206
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
207 207
 
208 208
 /**
209 209
  * Donation Form Validate Fields
@@ -215,45 +215,45 @@  discard block
 block discarded – undo
215 215
 function give_purchase_form_validate_fields() {
216 216
 
217 217
 	// Check if there is $_POST
218
-	if ( empty( $_POST ) ) {
218
+	if (empty($_POST)) {
219 219
 		return false;
220 220
 	}
221 221
 
222
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
222
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
223 223
 
224 224
 	// Start an array to collect valid data
225 225
 	$valid_data = array(
226 226
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
227
-		'need_new_user'    => false,     // New user flag
228
-		'need_user_login'  => false,     // Login user flag
229
-		'logged_user_data' => array(),   // Logged user collected data
230
-		'new_user_data'    => array(),   // New user collected data
231
-		'login_user_data'  => array(),   // Login user collected data
232
-		'guest_user_data'  => array(),   // Guest user collected data
227
+		'need_new_user'    => false, // New user flag
228
+		'need_user_login'  => false, // Login user flag
229
+		'logged_user_data' => array(), // Logged user collected data
230
+		'new_user_data'    => array(), // New user collected data
231
+		'login_user_data'  => array(), // Login user collected data
232
+		'guest_user_data'  => array(), // Guest user collected data
233 233
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
234 234
 	);
235 235
 
236 236
 	//Validate Honeypot First
237
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
238
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
237
+	if ( ! empty($_POST['give-honeypot'])) {
238
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
239 239
 	}
240 240
 
241 241
 	// Validate agree to terms
242
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
243
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
242
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
243
+	if (isset($terms_option) && $terms_option === 'yes') {
244 244
 		give_purchase_form_validate_agree_to_terms();
245 245
 	}
246 246
 
247
-	if ( is_user_logged_in() ) {
247
+	if (is_user_logged_in()) {
248 248
 		// Collect logged in user data
249 249
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
250
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
250
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
251 251
 		// Set new user registration as required
252 252
 		$valid_data['need_new_user'] = true;
253 253
 		// Validate new user data
254 254
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
255 255
 		// Check if login validation is needed
256
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
256
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
257 257
 		// Set user login as required
258 258
 		$valid_data['need_user_login'] = true;
259 259
 		// Validate users login info
@@ -278,41 +278,41 @@  discard block
 block discarded – undo
278 278
  */
279 279
 function give_purchase_form_validate_gateway() {
280 280
 
281
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
282
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
283
-	$gateway = give_get_default_gateway( $form_id );
281
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
282
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
283
+	$gateway = give_get_default_gateway($form_id);
284 284
 
285 285
 	// Check if a gateway value is present
286
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
286
+	if ( ! empty($_REQUEST['give-gateway'])) {
287 287
 
288
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
288
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
289 289
 
290 290
 		//Is amount being donated in LIVE mode 0.00? If so, error:
291
-		if ( $amount == 0 && ! give_is_test_mode() ) {
291
+		if ($amount == 0 && ! give_is_test_mode()) {
292 292
 
293
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
293
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
294 294
 
295 295
 		} //Check for a minimum custom amount
296
-		elseif ( ! give_verify_minimum_price() ) {
296
+		elseif ( ! give_verify_minimum_price()) {
297 297
 
298 298
 			give_set_error(
299 299
 				'invalid_donation_minimum',
300 300
 				sprintf(
301 301
 					/* translators: %s: minimum donation amount */
302
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
303
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
302
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
303
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
304 304
 				)
305 305
 			);
306 306
 
307 307
 		} //Is this test mode zero donation? Let it through but set to manual gateway
308
-		elseif ( $amount == 0 && give_is_test_mode() ) {
308
+		elseif ($amount == 0 && give_is_test_mode()) {
309 309
 
310 310
 			$gateway = 'manual';
311 311
 
312 312
 		} //Check if this gateway is active
313
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
313
+		elseif ( ! give_is_gateway_active($gateway)) {
314 314
 
315
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
315
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
316 316
 
317 317
 		}
318 318
 
@@ -331,23 +331,23 @@  discard block
 block discarded – undo
331 331
  */
332 332
 function give_verify_minimum_price() {
333 333
 
334
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
335
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
336
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
337
-	$variable_prices = give_has_variable_prices( $form_id );
334
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
335
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
336
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
337
+	$variable_prices = give_has_variable_prices($form_id);
338 338
 
339
-	if ( $variable_prices && ! empty( $price_id ) ) {
339
+	if ($variable_prices && ! empty($price_id)) {
340 340
 
341
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
341
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
342 342
 
343
-		if ( $price_level_amount == $amount ) {
343
+		if ($price_level_amount == $amount) {
344 344
 			return true;
345 345
 		}
346 346
 	}
347 347
 
348
-	$minimum = give_get_form_minimum_price( $form_id );
348
+	$minimum = give_get_form_minimum_price($form_id);
349 349
 
350
-	if ( $minimum > $amount ) {
350
+	if ($minimum > $amount) {
351 351
 		return false;
352 352
 	}
353 353
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
  */
364 364
 function give_purchase_form_validate_agree_to_terms() {
365 365
 	// Validate agree to terms
366
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
366
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
367 367
 		// User did not agree
368
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) );
368
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give')));
369 369
 	}
370 370
 }
371 371
 
@@ -379,43 +379,43 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return      array
381 381
  */
382
-function give_purchase_form_required_fields( $form_id ) {
382
+function give_purchase_form_required_fields($form_id) {
383 383
 
384
-	$payment_mode = give_get_chosen_gateway( $form_id );
384
+	$payment_mode = give_get_chosen_gateway($form_id);
385 385
 
386 386
 	$required_fields = array(
387 387
 		'give_email' => array(
388 388
 			'error_id'      => 'invalid_email',
389
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' )
389
+			'error_message' => esc_html__('Please enter a valid email address.', 'give')
390 390
 		),
391 391
 		'give_first' => array(
392 392
 			'error_id'      => 'invalid_first_name',
393
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' )
393
+			'error_message' => esc_html__('Please enter your first name.', 'give')
394 394
 		)
395 395
 	);
396 396
 
397
-	$require_address = give_require_billing_address( $payment_mode );
397
+	$require_address = give_require_billing_address($payment_mode);
398 398
 
399
-	if ( $require_address ) {
400
-		$required_fields['card_address']    = array(
399
+	if ($require_address) {
400
+		$required_fields['card_address'] = array(
401 401
 			'error_id'      => 'invalid_card_address',
402
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' )
402
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give')
403 403
 		);
404
-		$required_fields['card_zip']        = array(
404
+		$required_fields['card_zip'] = array(
405 405
 			'error_id'      => 'invalid_zip_code',
406
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' )
406
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give')
407 407
 		);
408
-		$required_fields['card_city']       = array(
408
+		$required_fields['card_city'] = array(
409 409
 			'error_id'      => 'invalid_city',
410
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' )
410
+			'error_message' => esc_html__('Please enter your billing city.', 'give')
411 411
 		);
412 412
 		$required_fields['billing_country'] = array(
413 413
 			'error_id'      => 'invalid_country',
414
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' )
414
+			'error_message' => esc_html__('Please select your billing country.', 'give')
415 415
 		);
416
-		$required_fields['card_state']      = array(
416
+		$required_fields['card_state'] = array(
417 417
 			'error_id'      => 'invalid_state',
418
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' )
418
+			'error_message' => esc_html__('Please enter billing state / province.', 'give')
419 419
 		);
420 420
 	}
421 421
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @since 1.7
426 426
 	 */
427
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
427
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
428 428
 
429 429
 	return $required_fields;
430 430
 
@@ -439,16 +439,16 @@  discard block
 block discarded – undo
439 439
  *
440 440
  * @return mixed|void
441 441
  */
442
-function give_require_billing_address( $payment_mode ) {
442
+function give_require_billing_address($payment_mode) {
443 443
 
444 444
 	$return = false;
445 445
 
446
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
446
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
447 447
 		$return = true;
448 448
 	}
449 449
 
450 450
 	// Let payment gateways and other extensions determine if address fields should be required
451
-	return apply_filters( 'give_require_billing_address', $return );
451
+	return apply_filters('give_require_billing_address', $return);
452 452
 
453 453
 }
454 454
 
@@ -462,43 +462,43 @@  discard block
 block discarded – undo
462 462
 function give_purchase_form_validate_logged_in_user() {
463 463
 	global $user_ID;
464 464
 
465
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
465
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
466 466
 
467 467
 	// Start empty array to collect valid user data
468 468
 	$valid_user_data = array(
469 469
 		// Assume there will be errors
470
-		'user_id' => - 1
470
+		'user_id' => -1
471 471
 	);
472 472
 
473 473
 	// Verify there is a user_ID
474
-	if ( $user_ID > 0 ) {
474
+	if ($user_ID > 0) {
475 475
 		// Get the logged in user data
476
-		$user_data = get_userdata( $user_ID );
476
+		$user_data = get_userdata($user_ID);
477 477
 
478 478
 		// Loop through required fields and show error messages
479
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
480
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
481
-				give_set_error( $value['error_id'], $value['error_message'] );
479
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
480
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
481
+				give_set_error($value['error_id'], $value['error_message']);
482 482
 			}
483 483
 		}
484 484
 
485 485
 		// Verify data
486
-		if ( $user_data ) {
486
+		if ($user_data) {
487 487
 			// Collected logged in user data
488 488
 			$valid_user_data = array(
489 489
 				'user_id'    => $user_ID,
490
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
491
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
492
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
490
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
491
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
492
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
493 493
 			);
494 494
 
495
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
496
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
495
+			if ( ! is_email($valid_user_data['user_email'])) {
496
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
497 497
 			}
498 498
 
499 499
 		} else {
500 500
 			// Set invalid user error
501
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
501
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
502 502
 		}
503 503
 	}
504 504
 
@@ -516,90 +516,90 @@  discard block
 block discarded – undo
516 516
 function give_purchase_form_validate_new_user() {
517 517
 
518 518
 	$registering_new_user = false;
519
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
519
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
520 520
 
521 521
 	// Start an empty array to collect valid user data
522 522
 	$valid_user_data = array(
523 523
 		// Assume there will be errors
524
-		'user_id'    => - 1,
524
+		'user_id'    => -1,
525 525
 		// Get first name
526
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
526
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
527 527
 		// Get last name
528
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
528
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
529 529
 	);
530 530
 
531 531
 	// Check the new user's credentials against existing ones
532
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
533
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
534
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
535
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
532
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
533
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
534
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
535
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
536 536
 
537 537
 	// Loop through required fields and show error messages
538
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
539
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
540
-			give_set_error( $value['error_id'], $value['error_message'] );
538
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
539
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
540
+			give_set_error($value['error_id'], $value['error_message']);
541 541
 		}
542 542
 	}
543 543
 
544 544
 	// Check if we have an username to register
545
-	if ( $user_login && strlen( $user_login ) > 0 ) {
545
+	if ($user_login && strlen($user_login) > 0) {
546 546
 		$registering_new_user = true;
547 547
 
548 548
 		// We have an user name, check if it already exists
549
-		if ( username_exists( $user_login ) ) {
549
+		if (username_exists($user_login)) {
550 550
 			// Username already registered
551
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
551
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
552 552
 			// Check if it's valid
553
-		} else if ( ! give_validate_username( $user_login ) ) {
553
+		} else if ( ! give_validate_username($user_login)) {
554 554
 			// Invalid username
555
-			if ( is_multisite() ) {
556
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
555
+			if (is_multisite()) {
556
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
557 557
 			} else {
558
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
558
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
559 559
 			}
560 560
 		} else {
561 561
 			// All the checks have run and it's good to go
562 562
 			$valid_user_data['user_login'] = $user_login;
563 563
 		}
564
-	} elseif ( give_logged_in_only( $form_id ) ) {
565
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
564
+	} elseif (give_logged_in_only($form_id)) {
565
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
566 566
 	}
567 567
 
568 568
 	// Check if we have an email to verify
569
-	if ( $user_email && strlen( $user_email ) > 0 ) {
569
+	if ($user_email && strlen($user_email) > 0) {
570 570
 		// Validate email
571
-		if ( ! is_email( $user_email ) ) {
572
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
571
+		if ( ! is_email($user_email)) {
572
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
573 573
 			// Check if email exists
574
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
575
-			give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
574
+		} else if (email_exists($user_email) && $registering_new_user) {
575
+			give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
576 576
 		} else {
577 577
 			// All the checks have run and it's good to go
578 578
 			$valid_user_data['user_email'] = $user_email;
579 579
 		}
580 580
 	} else {
581 581
 		// No email
582
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
582
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
583 583
 	}
584 584
 
585 585
 	// Check password
586
-	if ( $user_pass && $pass_confirm ) {
586
+	if ($user_pass && $pass_confirm) {
587 587
 		// Verify confirmation matches
588
-		if ( $user_pass != $pass_confirm ) {
588
+		if ($user_pass != $pass_confirm) {
589 589
 			// Passwords do not match
590
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
590
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
591 591
 		} else {
592 592
 			// All is good to go
593 593
 			$valid_user_data['user_pass'] = $user_pass;
594 594
 		}
595 595
 	} else {
596 596
 		// Password or confirmation missing
597
-		if ( ! $user_pass && $registering_new_user ) {
597
+		if ( ! $user_pass && $registering_new_user) {
598 598
 			// The password is invalid
599
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
600
-		} else if ( ! $pass_confirm && $registering_new_user ) {
599
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
600
+		} else if ( ! $pass_confirm && $registering_new_user) {
601 601
 			// Confirmation password is invalid
602
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
602
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
603 603
 		}
604 604
 	}
605 605
 
@@ -618,36 +618,36 @@  discard block
 block discarded – undo
618 618
 	// Start an array to collect valid user data
619 619
 	$valid_user_data = array(
620 620
 		// Assume there will be errors
621
-		'user_id' => - 1
621
+		'user_id' => -1
622 622
 	);
623 623
 
624 624
 	// Username
625
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
626
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
625
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
626
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
627 627
 
628 628
 		return $valid_user_data;
629 629
 	}
630 630
 
631 631
 	// Get the user by login
632
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
632
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
633 633
 
634 634
 	// Check if user exists
635
-	if ( $user_data ) {
635
+	if ($user_data) {
636 636
 		// Get password
637
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
637
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
638 638
 
639 639
 		// Check user_pass
640
-		if ( $user_pass ) {
640
+		if ($user_pass) {
641 641
 			// Check if password is valid
642
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
642
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
643 643
 				// Incorrect password
644 644
 				give_set_error(
645 645
 					'password_incorrect',
646 646
 					sprintf(
647 647
 						'%1$s <a href="%2$s">%3$s</a>',
648
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
649
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
650
-						esc_html__( 'Reset Password', 'give' )
648
+						esc_html__('The password you entered is incorrect.', 'give'),
649
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
650
+						esc_html__('Reset Password', 'give')
651 651
 					)
652 652
 				);
653 653
 				// All is correct
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 			}
665 665
 		} else {
666 666
 			// Empty password
667
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
667
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
668 668
 		}
669 669
 	} else {
670 670
 		// no username
671
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
671
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
672 672
 	}
673 673
 
674 674
 	return $valid_user_data;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
  */
684 684
 function give_purchase_form_validate_guest_user() {
685 685
 
686
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
686
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
687 687
 
688 688
 	// Start an array to collect valid user data
689 689
 	$valid_user_data = array(
@@ -692,32 +692,32 @@  discard block
 block discarded – undo
692 692
 	);
693 693
 
694 694
 	// Show error message if user must be logged in
695
-	if ( give_logged_in_only( $form_id ) ) {
696
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
695
+	if (give_logged_in_only($form_id)) {
696
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
697 697
 	}
698 698
 
699 699
 	// Get the guest email
700
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
700
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
701 701
 
702 702
 	// Check email
703
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
703
+	if ($guest_email && strlen($guest_email) > 0) {
704 704
 		// Validate email
705
-		if ( ! is_email( $guest_email ) ) {
705
+		if ( ! is_email($guest_email)) {
706 706
 			// Invalid email
707
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
707
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
708 708
 		} else {
709 709
 			// All is good to go
710 710
 			$valid_user_data['user_email'] = $guest_email;
711 711
 		}
712 712
 	} else {
713 713
 		// No email
714
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
714
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
715 715
 	}
716 716
 
717 717
 	// Loop through required fields and show error messages
718
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
719
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
720
-			give_set_error( $value['error_id'], $value['error_message'] );
718
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
719
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
720
+			give_set_error($value['error_id'], $value['error_message']);
721 721
 		}
722 722
 	}
723 723
 
@@ -733,36 +733,36 @@  discard block
 block discarded – undo
733 733
  * @since   1.0
734 734
  * @return  integer
735 735
  */
736
-function give_register_and_login_new_user( $user_data = array() ) {
736
+function give_register_and_login_new_user($user_data = array()) {
737 737
 	// Verify the array
738
-	if ( empty( $user_data ) ) {
739
-		return - 1;
738
+	if (empty($user_data)) {
739
+		return -1;
740 740
 	}
741 741
 
742
-	if ( give_get_errors() ) {
743
-		return - 1;
742
+	if (give_get_errors()) {
743
+		return -1;
744 744
 	}
745 745
 
746
-	$user_args = apply_filters( 'give_insert_user_args', array(
747
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
748
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
749
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
750
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
751
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
752
-		'user_registered' => date( 'Y-m-d H:i:s' ),
753
-		'role'            => get_option( 'default_role' )
754
-	), $user_data );
746
+	$user_args = apply_filters('give_insert_user_args', array(
747
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
748
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
749
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
750
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
751
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
752
+		'user_registered' => date('Y-m-d H:i:s'),
753
+		'role'            => get_option('default_role')
754
+	), $user_data);
755 755
 
756 756
 	// Insert new user
757
-	$user_id = wp_insert_user( $user_args );
757
+	$user_id = wp_insert_user($user_args);
758 758
 
759 759
 	// Validate inserted user
760
-	if ( is_wp_error( $user_id ) ) {
761
-		return - 1;
760
+	if (is_wp_error($user_id)) {
761
+		return -1;
762 762
 	}
763 763
 
764 764
 	// Allow themes and plugins to filter the user data
765
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
765
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
766 766
 
767 767
 	/**
768 768
 	 * Fires after inserting user.
@@ -772,10 +772,10 @@  discard block
 block discarded – undo
772 772
 	 * @param int   $user_id   User id.
773 773
 	 * @param array $user_data Array containing user data.
774 774
 	 */
775
-	do_action( 'give_insert_user', $user_id, $user_data );
775
+	do_action('give_insert_user', $user_id, $user_data);
776 776
 
777 777
 	// Login new user
778
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
778
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
779 779
 
780 780
 	// Return user id
781 781
 	return $user_id;
@@ -790,27 +790,27 @@  discard block
 block discarded – undo
790 790
  * @since   1.0
791 791
  * @return  array
792 792
  */
793
-function give_get_purchase_form_user( $valid_data = array() ) {
793
+function give_get_purchase_form_user($valid_data = array()) {
794 794
 
795 795
 	// Initialize user
796 796
 	$user    = false;
797
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
797
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
798 798
 
799
-	if ( $is_ajax ) {
799
+	if ($is_ajax) {
800 800
 		// Do not create or login the user during the ajax submission (check for errors only)
801 801
 		return true;
802
-	} else if ( is_user_logged_in() ) {
802
+	} else if (is_user_logged_in()) {
803 803
 		// Set the valid user as the logged in collected data
804 804
 		$user = $valid_data['logged_in_user'];
805
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
805
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
806 806
 		// New user registration
807
-		if ( $valid_data['need_new_user'] === true ) {
807
+		if ($valid_data['need_new_user'] === true) {
808 808
 			// Set user
809 809
 			$user = $valid_data['new_user_data'];
810 810
 			// Register and login new user
811
-			$user['user_id'] = give_register_and_login_new_user( $user );
811
+			$user['user_id'] = give_register_and_login_new_user($user);
812 812
 			// User login
813
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
813
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
814 814
 
815 815
 			/*
816 816
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -825,48 +825,48 @@  discard block
 block discarded – undo
825 825
 			// Set user
826 826
 			$user = $valid_data['login_user_data'];
827 827
 			// Login user
828
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
828
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
829 829
 		}
830 830
 	}
831 831
 
832 832
 	// Check guest checkout
833
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
833
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
834 834
 		// Set user
835 835
 		$user = $valid_data['guest_user_data'];
836 836
 	}
837 837
 
838 838
 	// Verify we have an user
839
-	if ( false === $user || empty( $user ) ) {
839
+	if (false === $user || empty($user)) {
840 840
 		// Return false
841 841
 		return false;
842 842
 	}
843 843
 
844 844
 	// Get user first name
845
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
846
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
845
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
846
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
847 847
 	}
848 848
 
849 849
 	// Get user last name
850
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
851
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
850
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
851
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
852 852
 	}
853 853
 
854 854
 	// Get the user's billing address details
855 855
 	$user['address']            = array();
856
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
857
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
858
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
859
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
860
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
861
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
862
-
863
-	if ( empty( $user['address']['country'] ) ) {
856
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
857
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
858
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
859
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
860
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
861
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
862
+
863
+	if (empty($user['address']['country'])) {
864 864
 		$user['address'] = false;
865 865
 	} // Country will always be set if address fields are present
866 866
 
867
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
867
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
868 868
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
869
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
869
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
870 870
 	}
871 871
 
872 872
 	// Return valid user
@@ -885,16 +885,16 @@  discard block
 block discarded – undo
885 885
 	$card_data = give_get_purchase_cc_info();
886 886
 
887 887
 	// Validate the card zip
888
-	if ( ! empty( $card_data['card_zip'] ) ) {
889
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
890
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
888
+	if ( ! empty($card_data['card_zip'])) {
889
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
890
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
891 891
 		}
892 892
 	}
893 893
 
894 894
 	//Ensure no spaces
895
-	if ( ! empty( $card_data['card_number'] ) ) {
896
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
897
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
895
+	if ( ! empty($card_data['card_number'])) {
896
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
897
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
898 898
 	}
899 899
 
900 900
 	// This should validate card numbers at some point too
@@ -910,17 +910,17 @@  discard block
 block discarded – undo
910 910
  */
911 911
 function give_get_purchase_cc_info() {
912 912
 	$cc_info                   = array();
913
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
914
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
915
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
916
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
917
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
918
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
919
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
920
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
921
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
922
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
923
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
913
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
914
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
915
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
916
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
917
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
918
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
919
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
920
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
921
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
922
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
923
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
924 924
 
925 925
 	// Return cc info
926 926
 	return $cc_info;
@@ -936,14 +936,14 @@  discard block
 block discarded – undo
936 936
  *
937 937
  * @return bool|mixed|void
938 938
  */
939
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
939
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
940 940
 	$ret = false;
941 941
 
942
-	if ( empty( $zip ) || empty( $country_code ) ) {
942
+	if (empty($zip) || empty($country_code)) {
943 943
 		return $ret;
944 944
 	}
945 945
 
946
-	$country_code = strtoupper( $country_code );
946
+	$country_code = strtoupper($country_code);
947 947
 
948 948
 	$zip_regex = array(
949 949
 		"AD" => "AD\d{3}",
@@ -1103,11 +1103,11 @@  discard block
 block discarded – undo
1103 1103
 		"ZM" => "\d{5}"
1104 1104
 	);
1105 1105
 
1106
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1106
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1107 1107
 		$ret = true;
1108 1108
 	}
1109 1109
 
1110
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1110
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1111 1111
 }
1112 1112
 
1113 1113
 
@@ -1121,37 +1121,37 @@  discard block
 block discarded – undo
1121 1121
  *
1122 1122
  * @return bool
1123 1123
  */
1124
-function give_validate_multi_donation_form_level(  $valid_data, $data ) {
1124
+function give_validate_multi_donation_form_level($valid_data, $data) {
1125 1125
     /* @var Give_Donate_Form $form*/
1126
-    $form = new Give_Donate_Form( $data['give-form-id'] );
1126
+    $form = new Give_Donate_Form($data['give-form-id']);
1127 1127
 
1128 1128
     $donation_level_matched = false;
1129 1129
 
1130
-    if( $form->is_multi_type_donation_form() ) {
1130
+    if ($form->is_multi_type_donation_form()) {
1131 1131
 
1132 1132
         // Bailout.
1133
-        if( ! ( $variable_prices = $form->get_prices() ) ) {
1133
+        if ( ! ($variable_prices = $form->get_prices())) {
1134 1134
             return false;
1135 1135
         }
1136 1136
 
1137 1137
         // Sanitize donation amount.
1138
-        $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1138
+        $data['give-amount'] = give_sanitize_amount($data['give-amount']);
1139 1139
 
1140 1140
         // Get number of decimals.
1141 1141
         $default_decimals = give_get_price_decimals();
1142 1142
 
1143
-        if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1143
+        if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1144 1144
             return true;
1145 1145
         }
1146 1146
 
1147 1147
         
1148 1148
         // Find correct donation level from all donation levels.
1149
-        foreach ( $variable_prices as $variable_price ) {
1149
+        foreach ($variable_prices as $variable_price) {
1150 1150
             // Sanitize level amount.
1151
-            $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1151
+            $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1152 1152
 
1153 1153
             // Set first match donation level ID.
1154
-            if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1154
+            if ($data['give-amount'] === $variable_price['_give_amount']) {
1155 1155
                 $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1156 1156
                 $donation_level_matched = true;
1157 1157
                 break;
@@ -1160,20 +1160,20 @@  discard block
 block discarded – undo
1160 1160
 
1161 1161
         // If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1162 1162
         // If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1163
-        if(
1163
+        if (
1164 1164
             ! $donation_level_matched
1165
-            && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1165
+            && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1166 1166
         ) {
1167 1167
             // Sanitize custom minimum amount.
1168
-            $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1168
+            $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1169 1169
 
1170
-            if( $data['give-amount'] >= $custom_minimum_amount ) {
1170
+            if ($data['give-amount'] >= $custom_minimum_amount) {
1171 1171
                 $_POST['give-price-id'] = 'custom';
1172
-                $donation_level_matched  = true;
1172
+                $donation_level_matched = true;
1173 1173
             }
1174 1174
         }
1175 1175
     }
1176 1176
 
1177
-    return ( $donation_level_matched ? true : false );
1177
+    return ($donation_level_matched ? true : false);
1178 1178
 }
1179
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1180 1179
\ No newline at end of file
1180
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
1181 1181
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/offline-donations.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_donation_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_donation_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return void
42 42
  */
43
-function give_offline_payment_cc_form( $form_id ) {
43
+function give_offline_payment_cc_form($form_id) {
44 44
 
45
-	$post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true );
46
-	$post_offline_instructions         = get_post_meta( $form_id, '_give_offline_checkout_notes', true );
47
-	$global_offline_instruction        = give_get_option( 'global_offline_donation_content' );
45
+	$post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true);
46
+	$post_offline_instructions         = get_post_meta($form_id, '_give_offline_checkout_notes', true);
47
+	$global_offline_instruction        = give_get_option('global_offline_donation_content');
48 48
 	$offline_instructions              = $global_offline_instruction;
49 49
 
50
-	if ( $post_offline_customization_option == 'yes' ) {
50
+	if ($post_offline_customization_option == 'yes') {
51 51
 		$offline_instructions = $post_offline_instructions;
52 52
 	}
53 53
 
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param int $form_id Give form id.
62 62
 	 */
63
-	do_action( 'give_before_offline_info_fields', $form_id );
63
+	do_action('give_before_offline_info_fields', $form_id);
64 64
 	?>
65 65
 	<fieldset id="give_offline_payment_info">
66 66
 		<?php
67
-		$settings_url         = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
67
+		$settings_url         = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
68 68
 		/* translators: %s: form settings url */
69
-		$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
70
-		echo wpautop( stripslashes( $offline_instructions ) );
69
+		$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
70
+		echo wpautop(stripslashes($offline_instructions));
71 71
 		?>
72 72
 	</fieldset>
73 73
 	<?php
@@ -78,34 +78,34 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param int $form_id Give form id.
80 80
 	 */
81
-	do_action( 'give_after_offline_info_fields', $form_id );
81
+	do_action('give_after_offline_info_fields', $form_id);
82 82
 
83 83
 	echo ob_get_clean();
84 84
 }
85 85
 
86
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
86
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
87 87
 
88 88
 /**
89 89
  * Give Offline Billing Field
90 90
  *
91 91
  * @param $form_id
92 92
  */
93
-function give_offline_billing_fields( $form_id ) {
93
+function give_offline_billing_fields($form_id) {
94 94
 	//Enable Default CC fields (billing info)
95
-	$post_offline_cc_fields        = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
96
-	$post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true );
95
+	$post_offline_cc_fields        = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
96
+	$post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true);
97 97
 
98
-	$global_offline_cc_fields      = give_get_option( 'give_offline_donation_enable_billing_fields' );
98
+	$global_offline_cc_fields      = give_get_option('give_offline_donation_enable_billing_fields');
99 99
 
100 100
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
101
-	if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) {
102
-		give_default_cc_address_fields( $form_id );
103
-	} elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') {
104
-		give_default_cc_address_fields( $form_id );
101
+	if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') {
102
+		give_default_cc_address_fields($form_id);
103
+	} elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') {
104
+		give_default_cc_address_fields($form_id);
105 105
 	}
106 106
 }
107 107
 
108
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
108
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
109 109
 
110 110
 /**
111 111
  * Process the payment
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @return void
118 118
  */
119
-function give_offline_process_payment( $purchase_data ) {
119
+function give_offline_process_payment($purchase_data) {
120 120
 
121
-	$purchase_summary = give_get_purchase_summary( $purchase_data );
121
+	$purchase_summary = give_get_purchase_summary($purchase_data);
122 122
 
123 123
 	// setup the payment details
124 124
 	$payment_data = array(
125 125
 		'price'           => $purchase_data['price'],
126 126
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
127
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
128
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
127
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
128
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
129 129
 		'date'            => $purchase_data['date'],
130 130
 		'user_email'      => $purchase_data['user_email'],
131 131
 		'purchase_key'    => $purchase_data['purchase_key'],
@@ -137,20 +137,20 @@  discard block
 block discarded – undo
137 137
 
138 138
 
139 139
 	// record the pending payment
140
-	$payment = give_insert_payment( $payment_data );
140
+	$payment = give_insert_payment($payment_data);
141 141
 
142
-	if ( $payment ) {
143
-		give_offline_send_admin_notice( $payment );
144
-		give_offline_send_donor_instructions( $payment );
142
+	if ($payment) {
143
+		give_offline_send_admin_notice($payment);
144
+		give_offline_send_donor_instructions($payment);
145 145
 		give_send_to_success_page();
146 146
 	} else {
147 147
 		// if errors are present, send the user back to the donation form so they can be corrected
148
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
148
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
149 149
 	}
150 150
 
151 151
 }
152 152
 
153
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
153
+add_action('give_gateway_offline', 'give_offline_process_payment');
154 154
 
155 155
 
156 156
 /**
@@ -163,59 +163,59 @@  discard block
 block discarded – undo
163 163
  * @since       1.0
164 164
  * @return void
165 165
  */
166
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
166
+function give_offline_send_donor_instructions($payment_id = 0) {
167 167
 
168
-	$payment_data                      = give_get_payment_meta( $payment_id );
169
-	$post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
168
+	$payment_data                      = give_get_payment_meta($payment_id);
169
+	$post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
170 170
 
171 171
 	//Customize email content depending on whether the single form has been customized
172
-	$email_content = give_get_option( 'global_offline_donation_email' );
172
+	$email_content = give_get_option('global_offline_donation_email');
173 173
 
174
-	if ( $post_offline_customization_option === 'yes' ) {
175
-		$email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
174
+	if ($post_offline_customization_option === 'yes') {
175
+		$email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true);
176 176
 	}
177 177
 
178
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
178
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
179 179
 
180 180
 	/**
181 181
 	 * Filters the from name.
182 182
 	 *
183 183
 	 * @since 1.7
184 184
 	 */
185
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
185
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
186 186
 
187
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
187
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
188 188
 
189 189
 	/**
190 190
 	 * Filters the from email.
191 191
 	 *
192 192
 	 * @since 1.7
193 193
 	 */
194
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
194
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
195 195
 
196
-	$to_email = give_get_payment_user_email( $payment_id );
196
+	$to_email = give_get_payment_user_email($payment_id);
197 197
 
198
-	$subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) );
199
-	if ( $post_offline_customization_option === 'yes' ) {
200
-		$subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
198
+	$subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give'));
199
+	if ($post_offline_customization_option === 'yes') {
200
+		$subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
201 201
 	}
202 202
 
203
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
204
-	$subject = give_do_email_tags( $subject, $payment_id );
203
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
204
+	$subject = give_do_email_tags($subject, $payment_id);
205 205
 
206
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
207
-	$message     = give_do_email_tags( $email_content, $payment_id );
206
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
207
+	$message     = give_do_email_tags($email_content, $payment_id);
208 208
 
209 209
 	$emails = Give()->emails;
210 210
 
211
-	$emails->__set( 'from_name', $from_name );
212
-	$emails->__set( 'from_email', $from_email );
213
-	$emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) );
211
+	$emails->__set('from_name', $from_name);
212
+	$emails->__set('from_email', $from_email);
213
+	$emails->__set('heading', esc_html__('Offline Donation Instructions', 'give'));
214 214
 
215
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
216
-	$emails->__set( 'headers', $headers );
215
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
216
+	$emails->__set('headers', $headers);
217 217
 
218
-	$emails->send( $to_email, $subject, $message, $attachments );
218
+	$emails->send($to_email, $subject, $message, $attachments);
219 219
 
220 220
 }
221 221
 
@@ -232,52 +232,52 @@  discard block
 block discarded – undo
232 232
  * @return void
233 233
  *
234 234
  */
235
-function give_offline_send_admin_notice( $payment_id = 0 ) {
235
+function give_offline_send_admin_notice($payment_id = 0) {
236 236
 
237 237
 	/* Send an email notification to the admin */
238 238
 	$admin_email = give_get_admin_notice_emails();
239
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
239
+	$user_info   = give_get_payment_meta_user_info($payment_id);
240 240
 
241
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
242
-		$user_data = get_userdata( $user_info['id'] );
241
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
242
+		$user_data = get_userdata($user_info['id']);
243 243
 		$name      = $user_data->display_name;
244
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
245
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
244
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
245
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
246 246
 	} else {
247 247
 		$name = $user_info['email'];
248 248
 	}
249 249
 
250
-	$amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) );
250
+	$amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)));
251 251
 
252
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id );
252
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id);
253 253
 
254
-	$admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n";
255
-	$admin_message .= esc_attr__( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' ';
256
-	$admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
254
+	$admin_message = esc_attr__('Dear Admin,', 'give')."\n\n";
255
+	$admin_message .= esc_attr__('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' ';
256
+	$admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
257 257
 
258 258
 
259
-	$admin_message .= '<strong>' . esc_attr__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
260
-	$admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {price}' . "\n\n";
259
+	$admin_message .= '<strong>'.esc_attr__('Donor:', 'give').'</strong> {fullname}'."\n";
260
+	$admin_message .= '<strong>'.esc_attr__('Amount:', 'give').'</strong> {price}'."\n\n";
261 261
 
262 262
 	$admin_message .= sprintf(
263 263
 		'<a href="%1$s">%2$s</a>',
264
-		admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ),
265
-		esc_html__( 'Click Here to View and/or Update Donation Details', 'give' )
266
-	) . "\n\n";
264
+		admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id),
265
+		esc_html__('Click Here to View and/or Update Donation Details', 'give')
266
+	)."\n\n";
267 267
 
268
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
269
-	$admin_message = give_do_email_tags( $admin_message, $payment_id );
268
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
269
+	$admin_message = give_do_email_tags($admin_message, $payment_id);
270 270
 
271
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
272
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
271
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
272
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
273 273
 
274 274
 	//Send Email
275 275
 	$emails = Give()->emails;
276
-	if ( ! empty( $admin_headers ) ) {
277
-		$emails->__set( 'headers', $admin_headers );
276
+	if ( ! empty($admin_headers)) {
277
+		$emails->__set('headers', $admin_headers);
278 278
 	}
279 279
 
280
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
280
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
281 281
 
282 282
 }
283 283
 
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
  * @since  1.0
289 289
  * @return array
290 290
  */
291
-function give_offline_add_settings( $settings ) {
291
+function give_offline_add_settings($settings) {
292 292
 
293 293
 	//Vars
294 294
 	$prefix = '_give_';
295 295
 
296
-	$is_gateway_active = give_is_gateway_active( 'offline' );
296
+	$is_gateway_active = give_is_gateway_active('offline');
297 297
 
298 298
 	//this gateway isn't active
299
-	if ( ! $is_gateway_active ) {
299
+	if ( ! $is_gateway_active) {
300 300
 		//return settings and bounce
301 301
 		return $settings;
302 302
 	}
@@ -305,27 +305,27 @@  discard block
 block discarded – undo
305 305
 	$check_settings = array(
306 306
 
307 307
 		array(
308
-			'name'    => esc_attr__( 'Customize Offline Donations', 'give' ),
309
-			'desc'    => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ),
310
-			'id'      => $prefix . 'customize_offline_donations',
308
+			'name'    => esc_attr__('Customize Offline Donations', 'give'),
309
+			'desc'    => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'),
310
+			'id'      => $prefix.'customize_offline_donations',
311 311
 			'type'    => 'radio_inline',
312 312
 			'default' => 'no',
313 313
 			'options' => array(
314
-				'yes' => esc_attr__( 'Yes', 'give' ),
315
-				'no'  => esc_attr__( 'No', 'give' ),
314
+				'yes' => esc_attr__('Yes', 'give'),
315
+				'no'  => esc_attr__('No', 'give'),
316 316
 			),
317 317
 		),
318 318
 		array(
319
-			'name'        => esc_attr__( 'Request Billing Information', 'give' ),
320
-			'desc'        => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
321
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
319
+			'name'        => esc_attr__('Request Billing Information', 'give'),
320
+			'desc'        => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
321
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
322 322
 			'row_classes' => 'give-subfield',
323 323
 			'type'        => 'checkbox'
324 324
 		),
325 325
 		array(
326
-			'id'          => $prefix . 'offline_checkout_notes',
327
-			'name'        => esc_attr__( 'Offline Donation Instructions', 'give' ),
328
-			'desc'        => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
326
+			'id'          => $prefix.'offline_checkout_notes',
327
+			'name'        => esc_attr__('Offline Donation Instructions', 'give'),
328
+			'desc'        => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
329 329
 			'default'     => give_get_default_offline_donation_content(),
330 330
 			'type'        => 'wysiwyg',
331 331
 			'row_classes' => 'give-subfield',
@@ -334,17 +334,17 @@  discard block
 block discarded – undo
334 334
 			)
335 335
 		),
336 336
 		array(
337
-			'id'          => $prefix . 'offline_donation_subject',
338
-			'name'        => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ),
339
-			'desc'        => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ),
340
-			'default'     => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
337
+			'id'          => $prefix.'offline_donation_subject',
338
+			'name'        => esc_attr__('Offline Donation Email Instructions Subject', 'give'),
339
+			'desc'        => esc_attr__('Enter the subject line for the donation receipt email.', 'give'),
340
+			'default'     => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
341 341
 			'row_classes' => 'give-subfield',
342 342
 			'type'        => 'text'
343 343
 		),
344 344
 		array(
345
-			'id'          => $prefix . 'offline_donation_email',
346
-			'name'        => esc_attr__( 'Offline Donation Email Instructions', 'give' ),
347
-			'desc'        => esc_attr__( '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' ),
345
+			'id'          => $prefix.'offline_donation_email',
346
+			'name'        => esc_attr__('Offline Donation Email Instructions', 'give'),
347
+			'desc'        => esc_attr__('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'),
348 348
 			'default'     => give_get_default_offline_donation_email_content(),
349 349
 			'type'        => 'wysiwyg',
350 350
 			'row_classes' => 'give-subfield',
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 		)
355 355
 	);
356 356
 
357
-	return array_merge( $settings, $check_settings );
357
+	return array_merge($settings, $check_settings);
358 358
 }
359 359
 
360
-add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' );
360
+add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings');
361 361
 
362 362
 
363 363
 /**
@@ -369,32 +369,32 @@  discard block
 block discarded – undo
369 369
  */
370 370
 function give_get_default_offline_donation_content() {
371 371
 
372
-	$sitename = get_bloginfo( 'sitename' );
372
+	$sitename = get_bloginfo('sitename');
373 373
 
374
-	$default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
374
+	$default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
375 375
 	$default_text .= '<ol>';
376 376
 	$default_text .= '<li>';
377 377
 	$default_text .= sprintf(
378 378
 		/* translators: %s: site name */
379
-		esc_html__( 'Make a check payable to "%s"', 'give' ),
379
+		esc_html__('Make a check payable to "%s"', 'give'),
380 380
 		$sitename
381 381
 	);
382 382
 	$default_text .= '</li>';
383 383
 	$default_text .= '<li>';
384 384
 	$default_text .= sprintf(
385 385
 		/* translators: %s: site name */
386
-		esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
386
+		esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
387 387
 		$sitename
388 388
 	);
389 389
 	$default_text .= '</li>';
390
-	$default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>';
390
+	$default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>';
391 391
 	$default_text .= '</ol>';
392
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
392
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
393 393
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
394 394
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
395
-	$default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
395
+	$default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
396 396
 
397
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
397
+	return apply_filters('give_default_offline_donation_content', $default_text);
398 398
 
399 399
 }
400 400
 
@@ -407,33 +407,33 @@  discard block
 block discarded – undo
407 407
  */
408 408
 function give_get_default_offline_donation_email_content() {
409 409
 
410
-	$sitename      = get_bloginfo( 'sitename' );
411
-	$default_text  = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>';
412
-	$default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>';
410
+	$sitename      = get_bloginfo('sitename');
411
+	$default_text  = '<p>'.esc_html__('Dear {name},', 'give').'</p>';
412
+	$default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>';
413 413
 	$default_text .= '<ol>';
414 414
 	$default_text .= '<li>';
415 415
 	$default_text .= sprintf(
416 416
 		/* translators: %s: site name */
417
-		esc_html__( 'Make a check payable to "%s"', 'give' ),
417
+		esc_html__('Make a check payable to "%s"', 'give'),
418 418
 		$sitename
419 419
 	);
420 420
 	$default_text .= '</li>';
421 421
 	$default_text .= '<li>';
422 422
 	$default_text .= sprintf(
423 423
 		/* translators: %s: site name */
424
-		esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
424
+		esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
425 425
 		$sitename
426 426
 	);
427 427
 	$default_text .= '</li>';
428
-	$default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>';
428
+	$default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>';
429 429
 	$default_text .= '</ol>';
430
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
430
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
431 431
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
432 432
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
433
-	$default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>';
434
-	$default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>';
435
-	$default_text .= '<p>' . $sitename . '</p>';
433
+	$default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>';
434
+	$default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>';
435
+	$default_text .= '<p>'.$sitename.'</p>';
436 436
 
437
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
437
+	return apply_filters('give_default_offline_donation_content', $default_text);
438 438
 
439 439
 }
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  * @return void
39 39
  */
40 40
 function give_load_ajax_gateway() {
41
-	if ( isset( $_POST['give_payment_mode'] ) ) {
41
+	if (isset($_POST['give_payment_mode'])) {
42 42
 		/**
43 43
 		 * Fire to render donation form.
44 44
 		 *
45 45
 		 * @since 1.7
46 46
 		 */
47
-		do_action( 'give_donation_form', $_POST['give_form_id'] );
47
+		do_action('give_donation_form', $_POST['give_form_id']);
48 48
 
49 49
 		exit();
50 50
 	}
51 51
 }
52 52
 
53
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
54
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
53
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
54
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
55 55
 
56 56
 /**
57 57
  * Sets an error on checkout if no gateways are enabled
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 function give_no_gateway_error() {
64 64
 	$gateways = give_get_enabled_payment_gateways();
65 65
 
66
-	if ( empty( $gateways ) ) {
67
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
66
+	if (empty($gateways)) {
67
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
68 68
 	} else {
69
-		give_unset_error( 'no_gateways' );
69
+		give_unset_error('no_gateways');
70 70
 	}
71 71
 }
72 72
 
73
-add_action( 'init', 'give_no_gateway_error' );
73
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => esc_html__( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => esc_html__( 'PayPal', 'give' ),
29
-			'supports'       => array( 'buy_now' )
27
+			'admin_label'    => esc_html__('PayPal Standard', 'give'),
28
+			'checkout_label' => esc_html__('PayPal', 'give'),
29
+			'supports'       => array('buy_now')
30 30
 		),
31 31
 		'manual' => array(
32
-			'admin_label'    => esc_html__( 'Test Donation', 'give' ),
33
-			'checkout_label' => esc_html__( 'Test Donation', 'give' )
32
+			'admin_label'    => esc_html__('Test Donation', 'give'),
33
+			'checkout_label' => esc_html__('Test Donation', 'give')
34 34
 		),
35 35
 	);
36 36
 
37
-	return apply_filters( 'give_donation_gateways', $gateways );
37
+	return apply_filters('give_donation_gateways', $gateways);
38 38
 
39 39
 }
40 40
 
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 
49 49
 	$gateways = give_get_payment_gateways();
50 50
 
51
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
51
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
52 52
 
53 53
 	$gateway_list = array();
54 54
 
55
-	foreach ( $gateways as $key => $gateway ) {
56
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
57
-			$gateway_list[ $key ] = $gateway;
55
+	foreach ($gateways as $key => $gateway) {
56
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
57
+			$gateway_list[$key] = $gateway;
58 58
 		}
59 59
 	}
60 60
 
61 61
 	// Set order of payment gateway in list.
62
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
62
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
63 63
 
64
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list );
64
+	return apply_filters('give_enabled_payment_gateways', $gateway_list);
65 65
 }
66 66
 
67 67
 /**
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return boolean true if enabled, false otherwise
75 75
  */
76
-function give_is_gateway_active( $gateway ) {
76
+function give_is_gateway_active($gateway) {
77 77
 	$gateways = give_get_enabled_payment_gateways();
78 78
 
79
-	$ret = array_key_exists( $gateway, $gateways );
79
+	$ret = array_key_exists($gateway, $gateways);
80 80
 
81
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
81
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
82 82
 }
83 83
 
84 84
 /**
@@ -91,24 +91,24 @@  discard block
 block discarded – undo
91 91
  *
92 92
  * @return string Gateway ID
93 93
  */
94
-function give_get_default_gateway( $form_id ) {
94
+function give_get_default_gateway($form_id) {
95 95
 
96 96
 	global $give_options;
97 97
 
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = get_post_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = get_post_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	//Single Form settings varies compared to the Global default settings
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 	     $form_id !== null &&
104 104
 	     $default !== $form_default &&
105 105
 	     $form_default !== 'global' &&
106
-	     give_is_gateway_active( $form_default )
106
+	     give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_enabled_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_get_payment_amount( $payment ) == 0 ) {
130
-			$label = esc_html__( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_get_payment_amount($payment) == 0) {
130
+			$label = esc_html__('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_enabled_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = esc_html__( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = esc_html__('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return bool
181 181
  */
182
-function give_gateway_supports_buy_now( $gateway ) {
183
-	$supports = give_get_gateway_supports( $gateway );
184
-	$ret      = in_array( 'buy_now', $supports );
182
+function give_gateway_supports_buy_now($gateway) {
183
+	$supports = give_get_gateway_supports($gateway);
184
+	$ret      = in_array('buy_now', $supports);
185 185
 
186
-	return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway );
186
+	return apply_filters('give_gateway_supports_buy_now', $ret, $gateway);
187 187
 }
188 188
 
189 189
 /**
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	$gateways = give_get_enabled_payment_gateways();
197 197
 	$ret      = false;
198 198
 
199
-	if ( $gateways ) {
200
-		foreach ( $gateways as $gateway_id => $gateway ) {
201
-			if ( give_gateway_supports_buy_now( $gateway_id ) ) {
199
+	if ($gateways) {
200
+		foreach ($gateways as $gateway_id => $gateway) {
201
+			if (give_gateway_supports_buy_now($gateway_id)) {
202 202
 				$ret = true;
203 203
 				break;
204 204
 			}
205 205
 		}
206 206
 	}
207 207
 
208
-	return apply_filters( 'give_give_supports_buy_now', $ret );
208
+	return apply_filters('give_give_supports_buy_now', $ret);
209 209
 }
210 210
 
211 211
 /**
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return void
220 220
  */
221
-function give_send_to_gateway( $gateway, $payment_data ) {
221
+function give_send_to_gateway($gateway, $payment_data) {
222 222
 
223
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
223
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
224 224
 
225 225
 	/**
226 226
 	 * Fires while loading payment gateway via AJAX.
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @param array $payment_data All the payment data to be sent to the gateway.
233 233
 	 */
234
-	do_action( "give_gateway_{$gateway}", $payment_data );
234
+	do_action("give_gateway_{$gateway}", $payment_data);
235 235
 }
236 236
 
237 237
 
@@ -248,32 +248,32 @@  discard block
 block discarded – undo
248 248
  *
249 249
  * @return string $enabled_gateway The slug of the gateway
250 250
  */
251
-function give_get_chosen_gateway( $form_id ) {
251
+function give_get_chosen_gateway($form_id) {
252 252
 	$gateways        = give_get_enabled_payment_gateways();
253
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
254
-	if ( empty( $request_form_id ) ) {
255
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
253
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
254
+	if (empty($request_form_id)) {
255
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
256 256
 	}
257
-	$chosen          = give_get_default_gateway( $form_id );
257
+	$chosen          = give_get_default_gateway($form_id);
258 258
 	$enabled_gateway = '';
259 259
 
260 260
 	//Take into account request Form ID args
261
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
262
-		$chosen = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
261
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
262
+		$chosen = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
263 263
 	}
264 264
 
265
-	if ( $chosen ) {
266
-		$enabled_gateway = urldecode( $chosen );
267
-	} else if ( count( $gateways ) >= 1 && ! $chosen ) {
268
-		foreach ( $gateways as $gateway_id => $gateway ):
265
+	if ($chosen) {
266
+		$enabled_gateway = urldecode($chosen);
267
+	} else if (count($gateways) >= 1 && ! $chosen) {
268
+		foreach ($gateways as $gateway_id => $gateway):
269 269
 			$enabled_gateway = $gateway_id;
270 270
 		endforeach;
271 271
 	} else {
272
-		$enabled_gateway = give_get_default_gateway( $form_id );
272
+		$enabled_gateway = give_get_default_gateway($form_id);
273 273
 	}
274 274
 
275 275
 
276
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
276
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
277 277
 }
278 278
 
279 279
 /**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
  *
291 291
  * @return int ID of the new log entry
292 292
  */
293
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
294
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
293
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
294
+	return give_record_log($title, $message, $parent, 'gateway_error');
295 295
 }
296 296
 
297 297
 /**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
  *
305 305
  * @return int
306 306
  */
307
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
307
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
308 308
 
309 309
 	$ret  = 0;
310 310
 	$args = array(
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 		'fields'      => 'ids'
317 317
 	);
318 318
 
319
-	$payments = new WP_Query( $args );
319
+	$payments = new WP_Query($args);
320 320
 
321
-	if ( $payments ) {
321
+	if ($payments) {
322 322
 		$ret = $payments->post_count;
323 323
 	}
324 324
 
@@ -335,27 +335,27 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @return array $gateways All the available gateways
337 337
  */
338
-function give_get_ordered_payment_gateways( $gateways ) {
338
+function give_get_ordered_payment_gateways($gateways) {
339 339
 
340 340
 	//  Get gateways setting.
341
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
341
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
342 342
 
343 343
 	// Return from here if we do not have gateways setting.
344
-	if ( empty( $gateways_setting ) ) {
344
+	if (empty($gateways_setting)) {
345 345
 		return $gateways;
346 346
 	}
347 347
 
348 348
 	// Reverse array to order payment gateways.
349
-	$gateways_setting = array_reverse( $gateways_setting );
349
+	$gateways_setting = array_reverse($gateways_setting);
350 350
 
351 351
 	// Reorder gateways array
352
-	foreach ( $gateways_setting as $gateway_key => $value ) {
352
+	foreach ($gateways_setting as $gateway_key => $value) {
353 353
 
354
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
355
-		unset( $gateways[ $gateway_key ] );
354
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
355
+		unset($gateways[$gateway_key]);
356 356
 
357
-		if ( ! empty( $new_gateway_value ) ) {
358
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
357
+		if ( ! empty($new_gateway_value)) {
358
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
359 359
 		}
360 360
 	}
361 361
 
@@ -366,5 +366,5 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @param array $gateways All the available gateways
368 368
 	 */
369
-	return apply_filters( 'give_donation_gateways_order', $gateways );
369
+	return apply_filters('give_donation_gateways_order', $gateways);
370 370
 }
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +322 added lines, -322 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
 
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return mixed void|false
349 349
 	 */
350
-	public function __construct( $payment_id = false ) {
350
+	public function __construct($payment_id = false) {
351 351
 
352
-		if ( empty( $payment_id ) ) {
352
+		if (empty($payment_id)) {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		$this->setup_payment( $payment_id );
356
+		$this->setup_payment($payment_id);
357 357
 	}
358 358
 
359 359
 	/**
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @return mixed        The value
368 368
 	 */
369
-	public function __get( $key ) {
369
+	public function __get($key) {
370 370
 
371
-		if ( method_exists( $this, 'get_' . $key ) ) {
371
+		if (method_exists($this, 'get_'.$key)) {
372 372
 
373
-			$value = call_user_func( array( $this, 'get_' . $key ) );
373
+			$value = call_user_func(array($this, 'get_'.$key));
374 374
 
375 375
 		} else {
376 376
 
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 	 * @param  string $key The property name
393 393
 	 * @param  mixed $value The value of the property
394 394
 	 */
395
-	public function __set( $key, $value ) {
396
-		$ignore = array( '_ID' );
395
+	public function __set($key, $value) {
396
+		$ignore = array('_ID');
397 397
 
398
-		if ( $key === 'status' ) {
398
+		if ($key === 'status') {
399 399
 			$this->old_status = $this->status;
400 400
 		}
401 401
 
402
-		if ( ! in_array( $key, $ignore ) ) {
403
-			$this->pending[ $key ] = $value;
402
+		if ( ! in_array($key, $ignore)) {
403
+			$this->pending[$key] = $value;
404 404
 		}
405 405
 
406
-		if ( '_ID' !== $key ) {
406
+		if ('_ID' !== $key) {
407 407
 			$this->$key = $value;
408 408
 		}
409 409
 	}
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @return boolean       If the item is set or not
420 420
 	 */
421
-	public function __isset( $name ) {
422
-		if ( property_exists( $this, $name ) ) {
423
-			return false === empty( $this->$name );
421
+	public function __isset($name) {
422
+		if (property_exists($this, $name)) {
423
+			return false === empty($this->$name);
424 424
 		} else {
425 425
 			return null;
426 426
 		}
@@ -436,20 +436,20 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return bool            If the setup was successful or not
438 438
 	 */
439
-	private function setup_payment( $payment_id ) {
439
+	private function setup_payment($payment_id) {
440 440
 		$this->pending = array();
441 441
 
442
-		if ( empty( $payment_id ) ) {
442
+		if (empty($payment_id)) {
443 443
 			return false;
444 444
 		}
445 445
 
446
-		$payment = get_post( $payment_id );
446
+		$payment = get_post($payment_id);
447 447
 
448
-		if ( ! $payment || is_wp_error( $payment ) ) {
448
+		if ( ! $payment || is_wp_error($payment)) {
449 449
 			return false;
450 450
 		}
451 451
 
452
-		if ( 'give_payment' !== $payment->post_type ) {
452
+		if ('give_payment' !== $payment->post_type) {
453 453
 			return false;
454 454
 		}
455 455
 
@@ -463,13 +463,13 @@  discard block
 block discarded – undo
463 463
 		 * @param Give_Payment $this       Payment object.
464 464
 		 * @param int          $payment_id The ID of the payment.
465 465
 		 */
466
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
466
+		do_action('give_pre_setup_payment', $this, $payment_id);
467 467
 
468 468
 		// Primary Identifier
469
-		$this->ID = absint( $payment_id );
469
+		$this->ID = absint($payment_id);
470 470
 
471 471
 		// Protected ID that can never be changed
472
-		$this->_ID = absint( $payment_id );
472
+		$this->_ID = absint($payment_id);
473 473
 
474 474
 		// We have a payment, get the generic payment_meta item to reduce calls to it
475 475
 		$this->payment_meta = $this->get_meta();
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		$this->parent_payment = $payment->post_parent;
485 485
 
486 486
 		$all_payment_statuses  = give_get_payment_statuses();
487
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
487
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
488 488
 
489 489
 		// Items
490 490
 		$this->fees = $this->setup_fees();
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		 * @param Give_Payment $this       Payment object.
527 527
 		 * @param int          $payment_id The ID of the payment.
528 528
 		 */
529
-		do_action( 'give_setup_payment', $this, $payment_id );
529
+		do_action('give_setup_payment', $this, $payment_id);
530 530
 
531 531
 		return true;
532 532
 	}
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
      * 
545 545
      * @return void
546 546
      */
547
-    public function update_payment_setup( $payment_id ){
548
-        $this->setup_payment( $payment_id );
547
+    public function update_payment_setup($payment_id) {
548
+        $this->setup_payment($payment_id);
549 549
     }
550 550
 
551 551
 	/**
@@ -560,24 +560,24 @@  discard block
 block discarded – undo
560 560
 
561 561
 		// Construct the payment title
562 562
 		$payment_title = '';
563
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
564
-			$payment_title = $this->first_name . ' ' . $this->last_name;
565
-		} else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
563
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
564
+			$payment_title = $this->first_name.' '.$this->last_name;
565
+		} else if ( ! empty($this->first_name) && empty($this->last_name)) {
566 566
 			$payment_title = $this->first_name;
567
-		} else if ( ! empty( $this->email ) && is_email( $this->email ) ) {
567
+		} else if ( ! empty($this->email) && is_email($this->email)) {
568 568
 			$payment_title = $this->email;
569 569
 		}
570 570
 
571 571
 		//Set Key
572
-		if ( empty( $this->key ) ) {
572
+		if (empty($this->key)) {
573 573
 
574
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
575
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
574
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
575
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
576 576
 			$this->pending['key'] = $this->key;
577 577
 		}
578 578
 
579 579
 		//Set IP
580
-		if ( empty( $this->ip ) ) {
580
+		if (empty($this->ip)) {
581 581
 
582 582
 			$this->ip            = give_get_ip();
583 583
 			$this->pending['ip'] = $this->ip;
@@ -604,58 +604,58 @@  discard block
 block discarded – undo
604 604
 			'fees'         => $this->fees,
605 605
 		);
606 606
 
607
-		$args = apply_filters( 'give_insert_payment_args', array(
607
+		$args = apply_filters('give_insert_payment_args', array(
608 608
 			'post_title'    => $payment_title,
609 609
 			'post_status'   => $this->status,
610 610
 			'post_type'     => 'give_payment',
611
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
612
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
611
+			'post_date'     => ! empty($this->date) ? $this->date : null,
612
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
613 613
 			'post_parent'   => $this->parent_payment,
614
-		), $payment_data );
614
+		), $payment_data);
615 615
 
616 616
 		// Create a blank payment
617
-		$payment_id = wp_insert_post( $args );
617
+		$payment_id = wp_insert_post($args);
618 618
 
619
-		if ( ! empty( $payment_id ) ) {
619
+		if ( ! empty($payment_id)) {
620 620
 
621 621
 			$this->ID  = $payment_id;
622 622
 			$this->_ID = $payment_id;
623 623
 
624 624
 			$customer = new stdClass;
625 625
 
626
-			if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) {
627
-				$customer = new Give_Customer( get_current_user_id(), true );
626
+			if (did_action('give_pre_process_purchase') && is_user_logged_in()) {
627
+				$customer = new Give_Customer(get_current_user_id(), true);
628 628
 			}
629 629
 
630
-			if ( empty( $customer->id ) ) {
631
-				$customer = new Give_Customer( $this->email );
630
+			if (empty($customer->id)) {
631
+				$customer = new Give_Customer($this->email);
632 632
 			}
633 633
 
634
-			if ( empty( $customer->id ) ) {
634
+			if (empty($customer->id)) {
635 635
 
636 636
 				$customer_data = array(
637
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
637
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
638 638
 					'email'   => $this->email,
639 639
 					'user_id' => $this->user_id,
640 640
 				);
641 641
 
642
-				$customer->create( $customer_data );
642
+				$customer->create($customer_data);
643 643
 
644 644
 			}
645 645
 
646 646
 			$this->customer_id            = $customer->id;
647 647
 			$this->pending['customer_id'] = $this->customer_id;
648
-			$customer->attach_payment( $this->ID, false );
648
+			$customer->attach_payment($this->ID, false);
649 649
 
650
-			$this->payment_meta = apply_filters( 'give_donation_meta', $this->payment_meta, $payment_data );
651
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
652
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
653
-				foreach ( $this->fees as $fee ) {
654
-					$this->increase_fees( $fee['amount'] );
650
+			$this->payment_meta = apply_filters('give_donation_meta', $this->payment_meta, $payment_data);
651
+			if ( ! empty($this->payment_meta['fees'])) {
652
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
653
+				foreach ($this->fees as $fee) {
654
+					$this->increase_fees($fee['amount']);
655 655
 				}
656 656
 			}
657 657
 
658
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
658
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
659 659
 			$this->new = true;
660 660
 		}
661 661
 
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 		$saved = false;
678 678
 
679 679
 		//Must have an ID 
680
-		if ( empty( $this->ID ) ) {
680
+		if (empty($this->ID)) {
681 681
 
682 682
 			$payment_id = $this->insert_payment();
683 683
 
684
-			if ( false === $payment_id ) {
684
+			if (false === $payment_id) {
685 685
 				$saved = false;
686 686
 			} else {
687 687
 				$this->ID = $payment_id;
@@ -690,48 +690,48 @@  discard block
 block discarded – undo
690 690
 		}
691 691
 
692 692
 		//Set ID if not matching
693
-		if ( $this->ID !== $this->_ID ) {
693
+		if ($this->ID !== $this->_ID) {
694 694
 			$this->ID = $this->_ID;
695 695
 		}
696 696
 
697 697
 		// If we have something pending, let's save it
698
-		if ( ! empty( $this->pending ) ) {
698
+		if ( ! empty($this->pending)) {
699 699
 
700 700
 			$total_increase = 0;
701 701
 			$total_decrease = 0;
702 702
 
703
-			foreach ( $this->pending as $key => $value ) {
703
+			foreach ($this->pending as $key => $value) {
704 704
 
705
-				switch ( $key ) {
705
+				switch ($key) {
706 706
 
707 707
 					case 'donations':
708 708
 						// Update totals for pending donations
709
-						foreach ( $this->pending[ $key ] as $item ) {
709
+						foreach ($this->pending[$key] as $item) {
710 710
 
711
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
712
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
711
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
712
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
713 713
 
714
-							switch ( $item['action'] ) {
714
+							switch ($item['action']) {
715 715
 
716 716
 								case 'add':
717 717
 
718 718
 									$price = $item['price'];
719 719
 
720
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
720
+									if ('publish' === $this->status || 'complete' === $this->status) {
721 721
 
722 722
 										// Add sales logs
723
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
723
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
724 724
 
725 725
 										$y = 0;
726
-										while ( $y < $quantity ) {
726
+										while ($y < $quantity) {
727 727
 
728
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
729
-											$y ++;
728
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
729
+											$y++;
730 730
 										}
731 731
 
732
-										$form = new Give_Donate_Form( $item['id'] );
733
-										$form->increase_sales( $quantity );
734
-										$form->increase_earnings( $price );
732
+										$form = new Give_Donate_Form($item['id']);
733
+										$form->increase_sales($quantity);
734
+										$form->increase_earnings($price);
735 735
 
736 736
 										$total_increase += $price;
737 737
 									}
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 										)
757 757
 									);
758 758
 
759
-									$found_logs = get_posts( $log_args );
760
-									foreach ( $found_logs as $log ) {
761
-										wp_delete_post( $log->ID, true );
759
+									$found_logs = get_posts($log_args);
760
+									foreach ($found_logs as $log) {
761
+										wp_delete_post($log->ID, true);
762 762
 									}
763 763
 
764
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
765
-										$form = new Give_Donate_Form( $item['id'] );
766
-										$form->decrease_sales( $quantity );
767
-										$form->decrease_earnings( $item['amount'] );
764
+									if ('publish' === $this->status || 'complete' === $this->status) {
765
+										$form = new Give_Donate_Form($item['id']);
766
+										$form->decrease_sales($quantity);
767
+										$form->decrease_earnings($item['amount']);
768 768
 
769 769
 										$total_decrease += $item['amount'];
770 770
 									}
@@ -777,17 +777,17 @@  discard block
 block discarded – undo
777 777
 
778 778
 					case 'fees':
779 779
 
780
-						if ( 'publish' !== $this->status && 'complete' !== $this->status ) {
780
+						if ('publish' !== $this->status && 'complete' !== $this->status) {
781 781
 							break;
782 782
 						}
783 783
 
784
-						if ( empty( $this->pending[ $key ] ) ) {
784
+						if (empty($this->pending[$key])) {
785 785
 							break;
786 786
 						}
787 787
 
788
-						foreach ( $this->pending[ $key ] as $fee ) {
788
+						foreach ($this->pending[$key] as $fee) {
789 789
 
790
-							switch ( $fee['action'] ) {
790
+							switch ($fee['action']) {
791 791
 
792 792
 								case 'add':
793 793
 									$total_increase += $fee['amount'];
@@ -804,43 +804,43 @@  discard block
 block discarded – undo
804 804
 						break;
805 805
 
806 806
 					case 'status':
807
-						$this->update_status( $this->status );
807
+						$this->update_status($this->status);
808 808
 						break;
809 809
 
810 810
 					case 'gateway':
811
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
811
+						$this->update_meta('_give_payment_gateway', $this->gateway);
812 812
 						break;
813 813
 
814 814
 					case 'mode':
815
-						$this->update_meta( '_give_payment_mode', $this->mode );
815
+						$this->update_meta('_give_payment_mode', $this->mode);
816 816
 						break;
817 817
 
818 818
 					case 'transaction_id':
819
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
819
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
820 820
 						break;
821 821
 
822 822
 					case 'ip':
823
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
823
+						$this->update_meta('_give_payment_user_ip', $this->ip);
824 824
 						break;
825 825
 
826 826
 					case 'customer_id':
827
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
827
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
828 828
 						break;
829 829
 
830 830
 					case 'user_id':
831
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
831
+						$this->update_meta('_give_payment_user_id', $this->user_id);
832 832
 						break;
833 833
 
834 834
 					case 'form_title':
835
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
835
+						$this->update_meta('_give_payment_form_title', $this->form_title);
836 836
 						break;
837 837
 
838 838
 					case 'form_id':
839
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
839
+						$this->update_meta('_give_payment_form_id', $this->form_id);
840 840
 						break;
841 841
 
842 842
 					case 'price_id':
843
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
843
+						$this->update_meta('_give_payment_price_id', $this->price_id);
844 844
 						break;
845 845
 
846 846
 					case 'first_name':
@@ -856,15 +856,15 @@  discard block
 block discarded – undo
856 856
 						break;
857 857
 
858 858
 					case 'email':
859
-						$this->update_meta( '_give_payment_user_email', $this->email );
859
+						$this->update_meta('_give_payment_user_email', $this->email);
860 860
 						break;
861 861
 
862 862
 					case 'key':
863
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
863
+						$this->update_meta('_give_payment_purchase_key', $this->key);
864 864
 						break;
865 865
 
866 866
 					case 'number':
867
-						$this->update_meta( '_give_payment_number', $this->number );
867
+						$this->update_meta('_give_payment_number', $this->number);
868 868
 						break;
869 869
 
870 870
 					case 'date':
@@ -874,11 +874,11 @@  discard block
 block discarded – undo
874 874
 							'edit_date' => true,
875 875
 						);
876 876
 
877
-						wp_update_post( $args );
877
+						wp_update_post($args);
878 878
 						break;
879 879
 
880 880
 					case 'completed_date':
881
-						$this->update_meta( '_give_completed_date', $this->completed_date );
881
+						$this->update_meta('_give_completed_date', $this->completed_date);
882 882
 						break;
883 883
 
884 884
 					case 'parent_payment':
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 							'post_parent' => $this->parent_payment,
888 888
 						);
889 889
 
890
-						wp_update_post( $args );
890
+						wp_update_post($args);
891 891
 						break;
892 892
 
893 893
 					default:
@@ -898,34 +898,34 @@  discard block
 block discarded – undo
898 898
 						 *
899 899
 						 * @param Give_Payment $this Payment object.
900 900
 						 */
901
-						do_action( 'give_donation_save', $this, $key );
901
+						do_action('give_donation_save', $this, $key);
902 902
 						break;
903 903
 				}
904 904
 			}
905 905
 
906
-			if ( 'pending' !== $this->status ) {
906
+			if ('pending' !== $this->status) {
907 907
 
908
-				$customer = new Give_Customer( $this->customer_id );
908
+				$customer = new Give_Customer($this->customer_id);
909 909
 
910 910
 				$total_change = $total_increase - $total_decrease;
911
-				if ( $total_change < 0 ) {
911
+				if ($total_change < 0) {
912 912
 
913
-					$total_change = - ( $total_change );
913
+					$total_change = - ($total_change);
914 914
 					// Decrease the customer's donation stats
915
-					$customer->decrease_value( $total_change );
916
-					give_decrease_total_earnings( $total_change );
915
+					$customer->decrease_value($total_change);
916
+					give_decrease_total_earnings($total_change);
917 917
 
918
-				} else if ( $total_change > 0 ) {
918
+				} else if ($total_change > 0) {
919 919
 
920 920
 					// Increase the customer's donation stats
921
-					$customer->increase_value( $total_change );
922
-					give_increase_total_earnings( $total_change );
921
+					$customer->increase_value($total_change);
922
+					give_increase_total_earnings($total_change);
923 923
 
924 924
 				}
925 925
 
926 926
 			}
927 927
 
928
-			$this->update_meta( '_give_payment_total', $this->total );
928
+			$this->update_meta('_give_payment_total', $this->total);
929 929
 
930 930
 			$new_meta = array(
931 931
 				'form_title' => $this->form_title,
@@ -937,12 +937,12 @@  discard block
 block discarded – undo
937 937
 			);
938 938
 
939 939
 			$meta        = $this->get_meta();
940
-			$merged_meta = array_merge( $meta, $new_meta );
940
+			$merged_meta = array_merge($meta, $new_meta);
941 941
 
942 942
 			// Only save the payment meta if it's changed
943
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
944
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
945
-				if ( false !== $updated ) {
943
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
944
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
945
+				if (false !== $updated) {
946 946
 					$saved = true;
947 947
 				}
948 948
 			}
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 			$saved         = true;
952 952
 		}
953 953
 
954
-		if ( true === $saved ) {
955
-			$this->setup_payment( $this->ID );
954
+		if (true === $saved) {
955
+			$this->setup_payment($this->ID);
956 956
 		}
957 957
 
958 958
 		return $saved;
@@ -970,12 +970,12 @@  discard block
 block discarded – undo
970 970
 	 *
971 971
 	 * @return bool           True when successful, false otherwise
972 972
 	 */
973
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
973
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
974 974
 
975
-		$donation = new Give_Donate_Form( $form_id );
975
+		$donation = new Give_Donate_Form($form_id);
976 976
 
977 977
 		// Bail if this post isn't a give donation form
978
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
978
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
979 979
 			return false;
980 980
 		}
981 981
 
@@ -986,60 +986,60 @@  discard block
 block discarded – undo
986 986
 			'fees'     => array(),
987 987
 		);
988 988
 
989
-		$args = wp_parse_args( apply_filters( 'give_donation_add_donation_args', $args, $donation->ID ), $defaults );
989
+		$args = wp_parse_args(apply_filters('give_donation_add_donation_args', $args, $donation->ID), $defaults);
990 990
 
991 991
 		// Allow overriding the price
992
-		if ( false !== $args['price'] ) {
992
+		if (false !== $args['price']) {
993 993
 			$item_price = $args['price'];
994 994
 		} else {
995 995
 
996 996
 			// Deal with variable pricing
997
-			if ( give_has_variable_prices( $donation->ID ) ) {
998
-				$prices     = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
997
+			if (give_has_variable_prices($donation->ID)) {
998
+				$prices     = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
999 999
 				$item_price = '';
1000 1000
 				//Loop through prices
1001
-				foreach ( $prices as $price ) {
1001
+				foreach ($prices as $price) {
1002 1002
 					//Find a match between price_id and level_id
1003 1003
 					//First verify array keys exists THEN make the match
1004
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1004
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1005 1005
 					     && $args['price_id'] == $price['_give_id']['level_id']
1006 1006
 					) {
1007 1007
 						$item_price = $price['_give_amount'];
1008 1008
 					}
1009 1009
 				}
1010 1010
 				//Fallback to the lowest price point
1011
-				if ( $item_price == '' ) {
1012
-					$item_price       = give_get_lowest_price_option( $donation->ID );
1013
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1011
+				if ($item_price == '') {
1012
+					$item_price       = give_get_lowest_price_option($donation->ID);
1013
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1014 1014
 				}
1015 1015
 			} else {
1016 1016
 				//Simple form price
1017
-				$item_price = give_get_form_price( $donation->ID );
1017
+				$item_price = give_get_form_price($donation->ID);
1018 1018
 			}
1019 1019
 
1020 1020
 		}
1021 1021
 
1022 1022
 		// Sanitizing the price here so we don't have a dozen calls later
1023
-		$item_price = give_sanitize_amount( $item_price );
1024
-		$total      = round( $item_price, give_currency_decimal_filter() );
1023
+		$item_price = give_sanitize_amount($item_price);
1024
+		$total      = round($item_price, give_currency_decimal_filter());
1025 1025
 
1026 1026
 		//Add Options
1027 1027
 		$default_options = array();
1028
-		if ( false !== $args['price_id'] ) {
1028
+		if (false !== $args['price_id']) {
1029 1029
 			$default_options['price_id'] = (int) $args['price_id'];
1030 1030
 		}
1031
-		$options = wp_parse_args( $options, $default_options );
1031
+		$options = wp_parse_args($options, $default_options);
1032 1032
 
1033 1033
 		// Do not allow totals to go negative
1034
-		if ( $total < 0 ) {
1034
+		if ($total < 0) {
1035 1035
 			$total = 0;
1036 1036
 		}
1037 1037
 
1038 1038
 		$donation = array(
1039 1039
 			'name'     => $donation->post_title,
1040 1040
 			'id'       => $donation->ID,
1041
-			'price'    => round( $total, give_currency_decimal_filter() ),
1042
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1041
+			'price'    => round($total, give_currency_decimal_filter()),
1042
+			'subtotal' => round($total, give_currency_decimal_filter()),
1043 1043
 			'fees'     => $args['fees'],
1044 1044
 			'price_id' => $args['price_id'],
1045 1045
 			'action'   => 'add',
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 
1049 1049
 		$this->pending['donations'][] = $donation;
1050 1050
 
1051
-		$this->increase_subtotal( $total );
1051
+		$this->increase_subtotal($total);
1052 1052
 
1053 1053
 		return true;
1054 1054
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @return bool           If the item was removed or not
1067 1067
 	 */
1068
-	public function remove_donation( $form_id, $args = array() ) {
1068
+	public function remove_donation($form_id, $args = array()) {
1069 1069
 
1070 1070
 		// Set some defaults
1071 1071
 		$defaults = array(
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
 			'price'    => false,
1074 1074
 			'price_id' => false,
1075 1075
 		);
1076
-		$args     = wp_parse_args( $args, $defaults );
1076
+		$args = wp_parse_args($args, $defaults);
1077 1077
 
1078
-		$form = new Give_Donate_Form( $form_id );
1078
+		$form = new Give_Donate_Form($form_id);
1079 1079
 
1080 1080
 		// Bail if this post isn't a valid give donation form
1081
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1081
+		if ( ! $form || $form->post_type !== 'give_forms') {
1082 1082
 			return false;
1083 1083
 		}
1084 1084
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 
1092 1092
 		$this->pending['donations'][] = $pending_args;
1093 1093
 
1094
-		$this->decrease_subtotal( $this->total );
1094
+		$this->decrease_subtotal($this->total);
1095 1095
 
1096 1096
 		return true;
1097 1097
 	}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @return bool          If the fee was added
1109 1109
 	 */
1110
-	public function add_fee( $args, $global = true ) {
1110
+	public function add_fee($args, $global = true) {
1111 1111
 
1112 1112
 		$default_args = array(
1113 1113
 			'label'    => '',
@@ -1117,16 +1117,16 @@  discard block
 block discarded – undo
1117 1117
 			'price_id' => 0,
1118 1118
 		);
1119 1119
 
1120
-		$fee          = wp_parse_args( $args, $default_args );
1120
+		$fee          = wp_parse_args($args, $default_args);
1121 1121
 		$this->fees[] = $fee;
1122 1122
 
1123 1123
 
1124 1124
 		$added_fee               = $fee;
1125 1125
 		$added_fee['action']     = 'add';
1126 1126
 		$this->pending['fees'][] = $added_fee;
1127
-		reset( $this->fees );
1127
+		reset($this->fees);
1128 1128
 
1129
-		$this->increase_fees( $fee['amount'] );
1129
+		$this->increase_fees($fee['amount']);
1130 1130
 
1131 1131
 		return true;
1132 1132
 	}
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
 	 *
1142 1142
 	 * @return bool     If the fee was removed successfully
1143 1143
 	 */
1144
-	public function remove_fee( $key ) {
1144
+	public function remove_fee($key) {
1145 1145
 		$removed = false;
1146 1146
 
1147
-		if ( is_numeric( $key ) ) {
1148
-			$removed = $this->remove_fee_by( 'index', $key );
1147
+		if (is_numeric($key)) {
1148
+			$removed = $this->remove_fee_by('index', $key);
1149 1149
 		}
1150 1150
 
1151 1151
 		return $removed;
@@ -1164,47 +1164,47 @@  discard block
 block discarded – undo
1164 1164
 	 *
1165 1165
 	 * @return boolean            If the item is removed
1166 1166
 	 */
1167
-	public function remove_fee_by( $key, $value, $global = false ) {
1167
+	public function remove_fee_by($key, $value, $global = false) {
1168 1168
 
1169
-		$allowed_fee_keys = apply_filters( 'give_donation_fee_keys', array(
1169
+		$allowed_fee_keys = apply_filters('give_donation_fee_keys', array(
1170 1170
 			'index',
1171 1171
 			'label',
1172 1172
 			'amount',
1173 1173
 			'type',
1174
-		) );
1174
+		));
1175 1175
 
1176
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1176
+		if ( ! in_array($key, $allowed_fee_keys)) {
1177 1177
 			return false;
1178 1178
 		}
1179 1179
 
1180 1180
 		$removed = false;
1181
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1181
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1182 1182
 
1183
-			$removed_fee             = $this->fees[ $value ];
1183
+			$removed_fee             = $this->fees[$value];
1184 1184
 			$removed_fee['action']   = 'remove';
1185 1185
 			$this->pending['fees'][] = $removed_fee;
1186 1186
 
1187
-			$this->decrease_fees( $removed_fee['amount'] );
1187
+			$this->decrease_fees($removed_fee['amount']);
1188 1188
 
1189
-			unset( $this->fees[ $value ] );
1189
+			unset($this->fees[$value]);
1190 1190
 			$removed = true;
1191 1191
 
1192
-		} else if ( 'index' !== $key ) {
1192
+		} else if ('index' !== $key) {
1193 1193
 
1194
-			foreach ( $this->fees as $index => $fee ) {
1194
+			foreach ($this->fees as $index => $fee) {
1195 1195
 
1196
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1196
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1197 1197
 
1198 1198
 					$removed_fee             = $fee;
1199 1199
 					$removed_fee['action']   = 'remove';
1200 1200
 					$this->pending['fees'][] = $removed_fee;
1201 1201
 
1202
-					$this->decrease_fees( $removed_fee['amount'] );
1202
+					$this->decrease_fees($removed_fee['amount']);
1203 1203
 
1204
-					unset( $this->fees[ $index ] );
1204
+					unset($this->fees[$index]);
1205 1205
 					$removed = true;
1206 1206
 
1207
-					if ( false === $global ) {
1207
+					if (false === $global) {
1208 1208
 						break;
1209 1209
 					}
1210 1210
 
@@ -1214,8 +1214,8 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 		}
1216 1216
 
1217
-		if ( true === $removed ) {
1218
-			$this->fees = array_values( $this->fees );
1217
+		if (true === $removed) {
1218
+			$this->fees = array_values($this->fees);
1219 1219
 		}
1220 1220
 
1221 1221
 		return $removed;
@@ -1231,14 +1231,14 @@  discard block
 block discarded – undo
1231 1231
 	 *
1232 1232
 	 * @return array        The Fees for the type specified
1233 1233
 	 */
1234
-	public function get_fees( $type = 'all' ) {
1234
+	public function get_fees($type = 'all') {
1235 1235
 		$fees = array();
1236 1236
 
1237
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1237
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1238 1238
 
1239
-			foreach ( $this->fees as $fee_id => $fee ) {
1239
+			foreach ($this->fees as $fee_id => $fee) {
1240 1240
 
1241
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1241
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1242 1242
 					continue;
1243 1243
 				}
1244 1244
 
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 			}
1249 1249
 		}
1250 1250
 
1251
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1251
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1252 1252
 	}
1253 1253
 
1254 1254
 	/**
@@ -1261,13 +1261,13 @@  discard block
 block discarded – undo
1261 1261
 	 *
1262 1262
 	 * @return void
1263 1263
 	 */
1264
-	public function add_note( $note = false ) {
1264
+	public function add_note($note = false) {
1265 1265
 		// Bail if no note specified
1266
-		if ( ! $note ) {
1266
+		if ( ! $note) {
1267 1267
 			return false;
1268 1268
 		}
1269 1269
 
1270
-		give_insert_payment_note( $this->ID, $note );
1270
+		give_insert_payment_note($this->ID, $note);
1271 1271
 	}
1272 1272
 
1273 1273
 	/**
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 *
1281 1281
 	 * @return void
1282 1282
 	 */
1283
-	private function increase_subtotal( $amount = 0.00 ) {
1283
+	private function increase_subtotal($amount = 0.00) {
1284 1284
 		$amount = (float) $amount;
1285 1285
 		$this->subtotal += $amount;
1286 1286
 
@@ -1297,11 +1297,11 @@  discard block
 block discarded – undo
1297 1297
 	 *
1298 1298
 	 * @return void
1299 1299
 	 */
1300
-	private function decrease_subtotal( $amount = 0.00 ) {
1300
+	private function decrease_subtotal($amount = 0.00) {
1301 1301
 		$amount = (float) $amount;
1302 1302
 		$this->subtotal -= $amount;
1303 1303
 
1304
-		if ( $this->subtotal < 0 ) {
1304
+		if ($this->subtotal < 0) {
1305 1305
 			$this->subtotal = 0;
1306 1306
 		}
1307 1307
 
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
 	 *
1319 1319
 	 * @return void
1320 1320
 	 */
1321
-	private function increase_fees( $amount = 0.00 ) {
1321
+	private function increase_fees($amount = 0.00) {
1322 1322
 		$amount = (float) $amount;
1323 1323
 		$this->fees_total += $amount;
1324 1324
 
@@ -1335,11 +1335,11 @@  discard block
 block discarded – undo
1335 1335
 	 *
1336 1336
 	 * @return void
1337 1337
 	 */
1338
-	private function decrease_fees( $amount = 0.00 ) {
1338
+	private function decrease_fees($amount = 0.00) {
1339 1339
 		$amount = (float) $amount;
1340 1340
 		$this->fees_total -= $amount;
1341 1341
 
1342
-		if ( $this->fees_total < 0 ) {
1342
+		if ($this->fees_total < 0) {
1343 1343
 			$this->fees_total = 0;
1344 1344
 		}
1345 1345
 
@@ -1368,25 +1368,25 @@  discard block
 block discarded – undo
1368 1368
 	 *
1369 1369
 	 * @return bool   $updated Returns if the status was successfully updated
1370 1370
 	 */
1371
-	public function update_status( $status = false ) {
1371
+	public function update_status($status = false) {
1372 1372
 
1373 1373
 		//standardize the 'complete(d)' status
1374
-		if ( $status == 'completed' || $status == 'complete' ) {
1374
+		if ($status == 'completed' || $status == 'complete') {
1375 1375
 			$status = 'publish';
1376 1376
 		}
1377 1377
 
1378
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1378
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1379 1379
 
1380
-		if ( $old_status === $status ) {
1380
+		if ($old_status === $status) {
1381 1381
 			return false; // Don't permit status changes that aren't changes
1382 1382
 		}
1383 1383
 
1384
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1384
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1385 1385
 
1386 1386
 		$updated = false;
1387 1387
 
1388 1388
 
1389
-		if ( $do_change ) {
1389
+		if ($do_change) {
1390 1390
 
1391 1391
 			/**
1392 1392
 			 * Fires before changing payment status.
@@ -1397,21 +1397,21 @@  discard block
 block discarded – undo
1397 1397
 			 * @param string $status     The new status.
1398 1398
 			 * @param string $old_status The old status.
1399 1399
 			 */
1400
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1400
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1401 1401
 
1402 1402
 			$update_fields = array(
1403 1403
 				'ID'          => $this->ID,
1404 1404
 				'post_status' => $status,
1405
-				'edit_date'   => current_time( 'mysql' )
1405
+				'edit_date'   => current_time('mysql')
1406 1406
 			);
1407 1407
 
1408
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1408
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1409 1409
 
1410 1410
 			$all_payment_statuses  = give_get_payment_statuses();
1411
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1411
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1412 1412
 
1413 1413
 			// Process any specific status functions
1414
-			switch ( $status ) {
1414
+			switch ($status) {
1415 1415
 				case 'refunded':
1416 1416
 					$this->process_refund();
1417 1417
 					break;
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 			 * @param string $status     The new status.
1439 1439
 			 * @param string $old_status The old status.
1440 1440
 			 */
1441
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1441
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1442 1442
 
1443 1443
 		}
1444 1444
 
@@ -1473,32 +1473,32 @@  discard block
 block discarded – undo
1473 1473
 	 *
1474 1474
 	 * @return mixed             The value from the post meta
1475 1475
 	 */
1476
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1476
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1477 1477
 
1478
-		$meta = get_post_meta( $this->ID, $meta_key, $single );
1478
+		$meta = get_post_meta($this->ID, $meta_key, $single);
1479 1479
 
1480
-		if ( $meta_key === '_give_payment_meta' ) {
1480
+		if ($meta_key === '_give_payment_meta') {
1481 1481
 
1482
-			if ( empty( $meta['key'] ) ) {
1482
+			if (empty($meta['key'])) {
1483 1483
 				$meta['key'] = $this->setup_payment_key();
1484 1484
 			}
1485 1485
 
1486
-			if ( empty( $meta['form_title'] ) ) {
1486
+			if (empty($meta['form_title'])) {
1487 1487
 				$meta['form_title'] = $this->setup_form_title();
1488 1488
 			}
1489 1489
 
1490
-			if ( empty( $meta['email'] ) ) {
1490
+			if (empty($meta['email'])) {
1491 1491
 				$meta['email'] = $this->setup_email();
1492 1492
 			}
1493 1493
 
1494
-			if ( empty( $meta['date'] ) ) {
1495
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1494
+			if (empty($meta['date'])) {
1495
+				$meta['date'] = get_post_field('post_date', $this->ID);
1496 1496
 			}
1497 1497
 		}
1498 1498
 
1499
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1499
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1500 1500
 
1501
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1501
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1502 1502
 	}
1503 1503
 
1504 1504
 	/**
@@ -1513,23 +1513,23 @@  discard block
 block discarded – undo
1513 1513
 	 *
1514 1514
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1515 1515
 	 */
1516
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1517
-		if ( empty( $meta_key ) ) {
1516
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1517
+		if (empty($meta_key)) {
1518 1518
 			return false;
1519 1519
 		}
1520 1520
 
1521
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1521
+		if ($meta_key == 'key' || $meta_key == 'date') {
1522 1522
 
1523 1523
 			$current_meta              = $this->get_meta();
1524
-			$current_meta[ $meta_key ] = $meta_value;
1524
+			$current_meta[$meta_key] = $meta_value;
1525 1525
 
1526 1526
 			$meta_key   = '_give_payment_meta';
1527 1527
 			$meta_value = $current_meta;
1528 1528
 
1529
-		} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1529
+		} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1530 1530
 
1531
-			$meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1532
-			update_post_meta( $this->ID, '_give_payment_user_email', $meta_value );
1531
+			$meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1532
+			update_post_meta($this->ID, '_give_payment_user_email', $meta_value);
1533 1533
 
1534 1534
 			$current_meta                       = $this->get_meta();
1535 1535
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1539,9 +1539,9 @@  discard block
 block discarded – undo
1539 1539
 
1540 1540
 		}
1541 1541
 
1542
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1542
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1543 1543
 
1544
-		return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1544
+		return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1545 1545
 	}
1546 1546
 
1547 1547
 	/**
@@ -1556,14 +1556,14 @@  discard block
 block discarded – undo
1556 1556
 		$process_refund = true;
1557 1557
 
1558 1558
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1559
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1559
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1560 1560
 			$process_refund = false;
1561 1561
 		}
1562 1562
 
1563 1563
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1564
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1564
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1565 1565
 
1566
-		if ( false === $process_refund ) {
1566
+		if (false === $process_refund) {
1567 1567
 			return;
1568 1568
 		}
1569 1569
 
@@ -1574,17 +1574,17 @@  discard block
 block discarded – undo
1574 1574
 		 *
1575 1575
 		 * @param Give_Payment $this Payment object.
1576 1576
 		 */
1577
-		do_action( 'give_pre_refund_payment', $this );
1577
+		do_action('give_pre_refund_payment', $this);
1578 1578
 
1579
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1580
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1581
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1579
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1580
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1581
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1582 1582
 
1583
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1583
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1584 1584
 		$this->delete_sales_logs();
1585 1585
 
1586 1586
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1587
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1587
+		delete_transient(md5('give_earnings_this_monththis_month'));
1588 1588
 
1589 1589
 		/**
1590 1590
 		 * Fires after refunding payment.
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 		 *
1594 1594
 		 * @param Give_Payment $this Payment object.
1595 1595
 		 */
1596
-		do_action( 'give_post_refund_payment', $this );
1596
+		do_action('give_post_refund_payment', $this);
1597 1597
 	}
1598 1598
 
1599 1599
 	/**
@@ -1620,29 +1620,29 @@  discard block
 block discarded – undo
1620 1620
 		$process_pending = true;
1621 1621
 
1622 1622
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1623
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1623
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1624 1624
 			$process_pending = false;
1625 1625
 		}
1626 1626
 
1627 1627
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1628
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1628
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1629 1629
 
1630
-		if ( false === $process_pending ) {
1630
+		if (false === $process_pending) {
1631 1631
 			return;
1632 1632
 		}
1633 1633
 
1634
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this );
1635
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this );
1636
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this );
1634
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this);
1635
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this);
1636
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this);
1637 1637
 
1638
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1638
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1639 1639
 		$this->delete_sales_logs();
1640 1640
 
1641 1641
 		$this->completed_date = false;
1642
-		$this->update_meta( '_give_completed_date', '' );
1642
+		$this->update_meta('_give_completed_date', '');
1643 1643
 
1644 1644
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1645
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1645
+		delete_transient(md5('give_earnings_this_monththis_month'));
1646 1646
 	}
1647 1647
 
1648 1648
     /**
@@ -1657,29 +1657,29 @@  discard block
 block discarded – undo
1657 1657
         $process_cancelled = true;
1658 1658
 
1659 1659
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1660
-        if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1660
+        if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1661 1661
             $process_cancelled = false;
1662 1662
         }
1663 1663
 
1664 1664
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1665
-        $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1665
+        $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1666 1666
 
1667
-        if ( false === $process_cancelled ) {
1667
+        if (false === $process_cancelled) {
1668 1668
             return;
1669 1669
         }
1670 1670
 
1671
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1672
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1673
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1671
+        $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this);
1672
+        $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this);
1673
+        $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this);
1674 1674
 
1675
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1675
+        $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1676 1676
         $this->delete_sales_logs();
1677 1677
 
1678 1678
         $this->completed_date = false;
1679
-        $this->update_meta( '_give_completed_date', '' );
1679
+        $this->update_meta('_give_completed_date', '');
1680 1680
 
1681 1681
         // Clear the This Month earnings (this_monththis_month is NOT a typo)
1682
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1682
+        delete_transient(md5('give_earnings_this_monththis_month'));
1683 1683
     }
1684 1684
 
1685 1685
     /**
@@ -1692,29 +1692,29 @@  discard block
 block discarded – undo
1692 1692
         $process_revoked = true;
1693 1693
 
1694 1694
         // If the payment was not in publish, don't decrement stats as they were never incremented
1695
-        if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1695
+        if ('publish' != $this->old_status || 'revoked' != $this->status) {
1696 1696
             $process_revoked = false;
1697 1697
         }
1698 1698
 
1699 1699
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1700
-        $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1700
+        $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1701 1701
 
1702
-        if ( false === $process_revoked ) {
1702
+        if (false === $process_revoked) {
1703 1703
             return;
1704 1704
         }
1705 1705
 
1706
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1707
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1708
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1706
+        $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this);
1707
+        $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this);
1708
+        $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this);
1709 1709
 
1710
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1710
+        $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1711 1711
         $this->delete_sales_logs();
1712 1712
 
1713 1713
         $this->completed_date = false;
1714
-        $this->update_meta( '_give_completed_date', '' );
1714
+        $this->update_meta('_give_completed_date', '');
1715 1715
 
1716 1716
         // Clear the This Month earnings (this_monththis_month is NOT a typo)
1717
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1717
+        delete_transient(md5('give_earnings_this_monththis_month'));
1718 1718
     }
1719 1719
 
1720 1720
 	/**
@@ -1729,25 +1729,25 @@  discard block
 block discarded – undo
1729 1729
 	 *
1730 1730
 	 * @return void
1731 1731
 	 */
1732
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1732
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1733 1733
 
1734
-		give_undo_purchase( false, $this->ID );
1734
+		give_undo_purchase(false, $this->ID);
1735 1735
 
1736 1736
 		// Decrease store earnings
1737
-		if ( true === $alter_store_earnings ) {
1738
-			give_decrease_total_earnings( $this->total );
1737
+		if (true === $alter_store_earnings) {
1738
+			give_decrease_total_earnings($this->total);
1739 1739
 		}
1740 1740
 
1741 1741
 		// Decrement the stats for the customer
1742
-		if ( ! empty( $this->customer_id ) ) {
1742
+		if ( ! empty($this->customer_id)) {
1743 1743
 
1744
-			$customer = new Give_Customer( $this->customer_id );
1744
+			$customer = new Give_Customer($this->customer_id);
1745 1745
 
1746
-			if ( true === $alter_customer_value ) {
1747
-				$customer->decrease_value( $this->total );
1746
+			if (true === $alter_customer_value) {
1747
+				$customer->decrease_value($this->total);
1748 1748
 			}
1749 1749
 
1750
-			if ( true === $alter_customer_purchase_count ) {
1750
+			if (true === $alter_customer_purchase_count) {
1751 1751
 				$customer->decrease_purchase_count();
1752 1752
 			}
1753 1753
 
@@ -1797,13 +1797,13 @@  discard block
 block discarded – undo
1797 1797
 	 * @return string The date the payment was completed
1798 1798
 	 */
1799 1799
 	private function setup_completed_date() {
1800
-		$payment = get_post( $this->ID );
1800
+		$payment = get_post($this->ID);
1801 1801
 
1802
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1802
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1803 1803
 			return false; // This payment was never completed
1804 1804
 		}
1805 1805
 
1806
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1806
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1807 1807
 
1808 1808
 		return $date;
1809 1809
 	}
@@ -1817,7 +1817,7 @@  discard block
 block discarded – undo
1817 1817
 	 * @return string The payment mode
1818 1818
 	 */
1819 1819
 	private function setup_mode() {
1820
-		return $this->get_meta( '_give_payment_mode' );
1820
+		return $this->get_meta('_give_payment_mode');
1821 1821
 	}
1822 1822
 
1823 1823
 	/**
@@ -1829,13 +1829,13 @@  discard block
 block discarded – undo
1829 1829
 	 * @return float The payment total
1830 1830
 	 */
1831 1831
 	private function setup_total() {
1832
-		$amount = $this->get_meta( '_give_payment_total', true );
1832
+		$amount = $this->get_meta('_give_payment_total', true);
1833 1833
 
1834
-		if ( empty( $amount ) && '0.00' != $amount ) {
1835
-			$meta = $this->get_meta( '_give_payment_meta', true );
1836
-			$meta = maybe_unserialize( $meta );
1834
+		if (empty($amount) && '0.00' != $amount) {
1835
+			$meta = $this->get_meta('_give_payment_meta', true);
1836
+			$meta = maybe_unserialize($meta);
1837 1837
 
1838
-			if ( isset( $meta['amount'] ) ) {
1838
+			if (isset($meta['amount'])) {
1839 1839
 				$amount = $meta['amount'];
1840 1840
 			}
1841 1841
 		}
@@ -1868,9 +1868,9 @@  discard block
 block discarded – undo
1868 1868
 	private function setup_fees_total() {
1869 1869
 		$fees_total = (float) 0.00;
1870 1870
 
1871
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1872
-		if ( ! empty( $payment_fees ) ) {
1873
-			foreach ( $payment_fees as $fee ) {
1871
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1872
+		if ( ! empty($payment_fees)) {
1873
+			foreach ($payment_fees as $fee) {
1874 1874
 				$fees_total += (float) $fee['amount'];
1875 1875
 			}
1876 1876
 		}
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
 	 * @return string The currency for the payment
1889 1889
 	 */
1890 1890
 	private function setup_currency() {
1891
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_donation_currency_default', give_get_currency(), $this );
1891
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_donation_currency_default', give_get_currency(), $this);
1892 1892
 
1893 1893
 		return $currency;
1894 1894
 	}
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
 	 * @return array The Fees
1903 1903
 	 */
1904 1904
 	private function setup_fees() {
1905
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1905
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1906 1906
 
1907 1907
 		return $payment_fees;
1908 1908
 	}
@@ -1916,7 +1916,7 @@  discard block
 block discarded – undo
1916 1916
 	 * @return string The gateway
1917 1917
 	 */
1918 1918
 	private function setup_gateway() {
1919
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1919
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1920 1920
 
1921 1921
 		return $gateway;
1922 1922
 	}
@@ -1930,12 +1930,12 @@  discard block
 block discarded – undo
1930 1930
 	 * @return string The donation ID
1931 1931
 	 */
1932 1932
 	private function setup_transaction_id() {
1933
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1933
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1934 1934
 
1935
-		if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
1935
+		if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
1936 1936
 
1937 1937
 			$gateway        = $this->gateway;
1938
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1938
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1939 1939
 
1940 1940
 		}
1941 1941
 
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 	 * @return string The IP address for the payment
1952 1952
 	 */
1953 1953
 	private function setup_ip() {
1954
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
1954
+		$ip = $this->get_meta('_give_payment_user_ip', true);
1955 1955
 
1956 1956
 		return $ip;
1957 1957
 	}
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 	 * @return int The Customer ID
1966 1966
 	 */
1967 1967
 	private function setup_customer_id() {
1968
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
1968
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
1969 1969
 
1970 1970
 		return $customer_id;
1971 1971
 	}
@@ -1979,7 +1979,7 @@  discard block
 block discarded – undo
1979 1979
 	 * @return int The User ID
1980 1980
 	 */
1981 1981
 	private function setup_user_id() {
1982
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
1982
+		$user_id = $this->get_meta('_give_payment_user_id', true);
1983 1983
 
1984 1984
 		return $user_id;
1985 1985
 	}
@@ -1993,10 +1993,10 @@  discard block
 block discarded – undo
1993 1993
 	 * @return string The email address for the payment
1994 1994
 	 */
1995 1995
 	private function setup_email() {
1996
-		$email = $this->get_meta( '_give_payment_user_email', true );
1996
+		$email = $this->get_meta('_give_payment_user_email', true);
1997 1997
 
1998
-		if ( empty( $email ) ) {
1999
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
1998
+		if (empty($email)) {
1999
+			$email = Give()->customers->get_column('email', $this->customer_id);
2000 2000
 		}
2001 2001
 
2002 2002
 		return $email;
@@ -2016,15 +2016,15 @@  discard block
 block discarded – undo
2016 2016
 			'last_name'  => $this->last_name,
2017 2017
 		);
2018 2018
 
2019
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
2020
-		$user_info = wp_parse_args( $user_info, $defaults );
2019
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
2020
+		$user_info = wp_parse_args($user_info, $defaults);
2021 2021
 
2022
-		if ( empty( $user_info ) ) {
2022
+		if (empty($user_info)) {
2023 2023
 			// Get the customer, but only if it's been created
2024
-			$customer = new Give_Customer( $this->customer_id );
2024
+			$customer = new Give_Customer($this->customer_id);
2025 2025
 
2026
-			if ( $customer->id > 0 ) {
2027
-				$name      = explode( ' ', $customer->name, 2 );
2026
+			if ($customer->id > 0) {
2027
+				$name      = explode(' ', $customer->name, 2);
2028 2028
 				$user_info = array(
2029 2029
 					'first_name' => $name[0],
2030 2030
 					'last_name'  => $name[1],
@@ -2034,29 +2034,29 @@  discard block
 block discarded – undo
2034 2034
 			}
2035 2035
 		} else {
2036 2036
 			// Get the customer, but only if it's been created
2037
-			$customer = new Give_Customer( $this->customer_id );
2038
-			if ( $customer->id > 0 ) {
2039
-				foreach ( $user_info as $key => $value ) {
2040
-					if ( ! empty( $value ) ) {
2037
+			$customer = new Give_Customer($this->customer_id);
2038
+			if ($customer->id > 0) {
2039
+				foreach ($user_info as $key => $value) {
2040
+					if ( ! empty($value)) {
2041 2041
 						continue;
2042 2042
 					}
2043 2043
 
2044
-					switch ( $key ) {
2044
+					switch ($key) {
2045 2045
 						case 'first_name':
2046
-							$name = explode( ' ', $customer->name, 2 );
2046
+							$name = explode(' ', $customer->name, 2);
2047 2047
 
2048
-							$user_info[ $key ] = $name[0];
2048
+							$user_info[$key] = $name[0];
2049 2049
 							break;
2050 2050
 
2051 2051
 						case 'last_name':
2052
-							$name      = explode( ' ', $customer->name, 2 );
2053
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
2052
+							$name      = explode(' ', $customer->name, 2);
2053
+							$last_name = ! empty($name[1]) ? $name[1] : '';
2054 2054
 
2055
-							$user_info[ $key ] = $last_name;
2055
+							$user_info[$key] = $last_name;
2056 2056
 							break;
2057 2057
 
2058 2058
 						case 'email':
2059
-							$user_info[ $key ] = $customer->email;
2059
+							$user_info[$key] = $customer->email;
2060 2060
 							break;
2061 2061
 					}
2062 2062
 				}
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 	 */
2079 2079
 	private function setup_address() {
2080 2080
 
2081
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
2081
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
2082 2082
 			'line1'   => '',
2083 2083
 			'line2'   => '',
2084 2084
 			'city'    => '',
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
 	 */
2101 2101
 	private function setup_form_title() {
2102 2102
 
2103
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
2103
+		$form_id = $this->get_meta('_give_payment_form_title', true);
2104 2104
 
2105 2105
 		return $form_id;
2106 2106
 	}
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 	 */
2116 2116
 	private function setup_form_id() {
2117 2117
 
2118
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
2118
+		$form_id = $this->get_meta('_give_payment_form_id', true);
2119 2119
 
2120 2120
 		return $form_id;
2121 2121
 	}
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 	 * @return int The Form Price ID
2130 2130
 	 */
2131 2131
 	private function setup_price_id() {
2132
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
2132
+		$price_id = $this->get_meta('_give_payment_price_id', true);
2133 2133
 
2134 2134
 		return $price_id;
2135 2135
 	}
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 	 * @return string The Payment Key
2144 2144
 	 */
2145 2145
 	private function setup_payment_key() {
2146
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
2146
+		$key = $this->get_meta('_give_payment_purchase_key', true);
2147 2147
 
2148 2148
 		return $key;
2149 2149
 	}
@@ -2159,11 +2159,11 @@  discard block
 block discarded – undo
2159 2159
 	private function setup_payment_number() {
2160 2160
 		$number = $this->ID;
2161 2161
 
2162
-		if ( give_get_option( 'enable_sequential' ) ) {
2162
+		if (give_get_option('enable_sequential')) {
2163 2163
 
2164
-			$number = $this->get_meta( '_give_payment_number', true );
2164
+			$number = $this->get_meta('_give_payment_number', true);
2165 2165
 
2166
-			if ( ! $number ) {
2166
+			if ( ! $number) {
2167 2167
 
2168 2168
 				$number = $this->ID;
2169 2169
 
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 	 * @return array The payment object as an array
2183 2183
 	 */
2184 2184
 	public function array_convert() {
2185
-		return get_object_vars( $this );
2185
+		return get_object_vars($this);
2186 2186
 	}
2187 2187
 
2188 2188
 	/**
@@ -2194,7 +2194,7 @@  discard block
 block discarded – undo
2194 2194
 	 * @return string Date payment was completed
2195 2195
 	 */
2196 2196
 	private function get_completed_date() {
2197
-		return apply_filters( 'give_donation_completed_date', $this->completed_date, $this->ID, $this );
2197
+		return apply_filters('give_donation_completed_date', $this->completed_date, $this->ID, $this);
2198 2198
 	}
2199 2199
 
2200 2200
 	/**
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 	 * @return float Payment subtotal
2207 2207
 	 */
2208 2208
 	private function get_subtotal() {
2209
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2209
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2210 2210
 	}
2211 2211
 
2212 2212
 	/**
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
 	 * @return string Payment currency code
2219 2219
 	 */
2220 2220
 	private function get_currency() {
2221
-		return apply_filters( 'give_donation_currency_code', $this->currency, $this->ID, $this );
2221
+		return apply_filters('give_donation_currency_code', $this->currency, $this->ID, $this);
2222 2222
 	}
2223 2223
 
2224 2224
 	/**
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 	 * @return string Gateway used
2231 2231
 	 */
2232 2232
 	private function get_gateway() {
2233
-		return apply_filters( 'give_donation_gateway', $this->gateway, $this->ID, $this );
2233
+		return apply_filters('give_donation_gateway', $this->gateway, $this->ID, $this);
2234 2234
 	}
2235 2235
 
2236 2236
 	/**
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 	 * @return string Donation ID from merchant processor
2243 2243
 	 */
2244 2244
 	private function get_transaction_id() {
2245
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2245
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2246 2246
 	}
2247 2247
 
2248 2248
 	/**
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 	 * @return string Payment IP address
2255 2255
 	 */
2256 2256
 	private function get_ip() {
2257
-		return apply_filters( 'give_donation_user_ip', $this->ip, $this->ID, $this );
2257
+		return apply_filters('give_donation_user_ip', $this->ip, $this->ID, $this);
2258 2258
 	}
2259 2259
 
2260 2260
 	/**
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 	 * @return int Payment customer ID
2267 2267
 	 */
2268 2268
 	private function get_customer_id() {
2269
-		return apply_filters( 'give_donation_customer_id', $this->customer_id, $this->ID, $this );
2269
+		return apply_filters('give_donation_customer_id', $this->customer_id, $this->ID, $this);
2270 2270
 	}
2271 2271
 
2272 2272
 	/**
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 	 * @return int Payment user ID
2279 2279
 	 */
2280 2280
 	private function get_user_id() {
2281
-		return apply_filters( 'give_donation_user_id', $this->user_id, $this->ID, $this );
2281
+		return apply_filters('give_donation_user_id', $this->user_id, $this->ID, $this);
2282 2282
 	}
2283 2283
 
2284 2284
 	/**
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @return string Payment customer email
2291 2291
 	 */
2292 2292
 	private function get_email() {
2293
-		return apply_filters( 'give_donation_user_email', $this->email, $this->ID, $this );
2293
+		return apply_filters('give_donation_user_email', $this->email, $this->ID, $this);
2294 2294
 	}
2295 2295
 
2296 2296
 	/**
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 	 * @return array Payment user info
2303 2303
 	 */
2304 2304
 	private function get_user_info() {
2305
-		return apply_filters( 'give_donation_meta_user_info', $this->user_info, $this->ID, $this );
2305
+		return apply_filters('give_donation_meta_user_info', $this->user_info, $this->ID, $this);
2306 2306
 	}
2307 2307
 
2308 2308
 	/**
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 	 * @return array Payment billing address
2315 2315
 	 */
2316 2316
 	private function get_address() {
2317
-		return apply_filters( 'give_donation_address', $this->address, $this->ID, $this );
2317
+		return apply_filters('give_donation_address', $this->address, $this->ID, $this);
2318 2318
 	}
2319 2319
 
2320 2320
 	/**
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
 	 * @return string Payment key
2327 2327
 	 */
2328 2328
 	private function get_key() {
2329
-		return apply_filters( 'give_donation_key', $this->key, $this->ID, $this );
2329
+		return apply_filters('give_donation_key', $this->key, $this->ID, $this);
2330 2330
 	}
2331 2331
 
2332 2332
 	/**
@@ -2338,7 +2338,7 @@  discard block
 block discarded – undo
2338 2338
 	 * @return string Payment form id
2339 2339
 	 */
2340 2340
 	private function get_form_id() {
2341
-		return apply_filters( 'give_donation_form_id', $this->form_id, $this->ID, $this );
2341
+		return apply_filters('give_donation_form_id', $this->form_id, $this->ID, $this);
2342 2342
 	}
2343 2343
 
2344 2344
 	/**
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
 	 * @return int|string Payment number
2351 2351
 	 */
2352 2352
 	private function get_number() {
2353
-		return apply_filters( 'give_donation_number', $this->number, $this->ID, $this );
2353
+		return apply_filters('give_donation_number', $this->number, $this->ID, $this);
2354 2354
 	}
2355 2355
 
2356 2356
 }
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
55
-		if ( empty( $form_id ) ) {
55
+		if (empty($form_id)) {
56 56
 
57 57
 			// Global sale stats
58
-			add_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
58
+			add_filter('give_count_payments_where', array($this, 'count_where'));
59 59
 
60
-			if ( is_array( $status ) ) {
60
+			if (is_array($status)) {
61 61
 				$count = 0;
62
-				foreach ( $status as $payment_status ) {
62
+				foreach ($status as $payment_status) {
63 63
 					$count += give_count_payments()->$payment_status;
64 64
 				}
65 65
 			} else {
66 66
 				$count = give_count_payments()->$status;
67 67
 			}
68 68
 
69
-			remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
69
+			remove_filter('give_count_payments_where', array($this, 'count_where'));
70 70
 
71 71
 		} else {
72 72
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			// Product specific stats
76 76
 			global $give_logs;
77 77
 
78
-			add_filter( 'posts_where', array( $this, 'payments_where' ) );
78
+			add_filter('posts_where', array($this, 'payments_where'));
79 79
 
80
-			$count = $give_logs->get_log_count( $form_id, 'sale' );
80
+			$count = $give_logs->get_log_count($form_id, 'sale');
81 81
 
82
-			remove_filter( 'posts_where', array( $this, 'payments_where' ) );
82
+			remove_filter('posts_where', array($this, 'payments_where'));
83 83
 
84 84
 		}
85 85
 
@@ -101,31 +101,31 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return float|int                Total amount of donations based on the passed arguments.
103 103
 	 */
104
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
104
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
105 105
 
106 106
 		global $wpdb;
107 107
 
108
-		$this->setup_dates( $start_date, $end_date );
108
+		$this->setup_dates($start_date, $end_date);
109 109
 
110 110
 		// Make sure start date is valid
111
-		if ( is_wp_error( $this->start_date ) ) {
111
+		if (is_wp_error($this->start_date)) {
112 112
 			return $this->start_date;
113 113
 		}
114 114
 
115 115
 		// Make sure end date is valid
116
-		if ( is_wp_error( $this->end_date ) ) {
116
+		if (is_wp_error($this->end_date)) {
117 117
 			return $this->end_date;
118 118
 		}
119 119
 
120
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
120
+		add_filter('posts_where', array($this, 'payments_where'));
121 121
 
122
-		if ( empty( $form_id ) ) {
122
+		if (empty($form_id)) {
123 123
 
124 124
 			// Global earning stats
125 125
 			$args = array(
126 126
 				'post_type'              => 'give_payment',
127 127
 				'nopaging'               => true,
128
-				'post_status'            => array( 'publish' ),
128
+				'post_status'            => array('publish'),
129 129
 				'fields'                 => 'ids',
130 130
 				'update_post_term_cache' => false,
131 131
 				'suppress_filters'       => false,
@@ -137,24 +137,24 @@  discard block
 block discarded – undo
137 137
 			);
138 138
 
139 139
 			//Filter by Gateway ID meta_key
140
-			if ( $gateway_id !== false ) {
140
+			if ($gateway_id !== false) {
141 141
 				$args['meta_key']   = '_give_payment_gateway';
142 142
 				$args['meta_value'] = $gateway_id;
143 143
 			}
144 144
 
145
-			$args = apply_filters( 'give_stats_earnings_args', $args );
146
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
147
-			$earnings = get_transient( $key );
145
+			$args = apply_filters('give_stats_earnings_args', $args);
146
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
147
+			$earnings = get_transient($key);
148 148
 			
149
-			if ( false === $earnings ) {
150
-				$sales    = get_posts( $args );
149
+			if (false === $earnings) {
150
+				$sales    = get_posts($args);
151 151
 				$earnings = 0;
152
-				if ( $sales ) {
153
-					$sales = implode( ',', array_map('intval', $sales ) );
154
-					$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
152
+				if ($sales) {
153
+					$sales = implode(',', array_map('intval', $sales));
154
+					$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
155 155
 				}
156 156
 				// Cache the results for one hour
157
-				set_transient( $key, $earnings, HOUR_IN_SECONDS );
157
+				set_transient($key, $earnings, HOUR_IN_SECONDS);
158 158
 			}
159 159
 
160 160
 		} else {
@@ -174,37 +174,37 @@  discard block
 block discarded – undo
174 174
 				'give_transient_type' => 'give_earnings',
175 175
 				// This is not a valid query arg, but is used for cache keying
176 176
 			);
177
-			$args = apply_filters( 'give_stats_earnings_args', $args );
178
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
177
+			$args = apply_filters('give_stats_earnings_args', $args);
178
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
179 179
 			//Set transient for faster stats
180
-			$earnings = get_transient( $key );
180
+			$earnings = get_transient($key);
181 181
 
182
-			if ( false === $earnings ) {
182
+			if (false === $earnings) {
183 183
 
184 184
 				$this->timestamp = false;
185
-				$log_ids  = $give_logs->get_connected_logs( $args, 'sale' );
185
+				$log_ids  = $give_logs->get_connected_logs($args, 'sale');
186 186
 				$earnings = 0;
187 187
 
188
-				if ( $log_ids ) {
189
-					$log_ids     = implode( ',', array_map('intval', $log_ids ) );
190
-					$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" );
188
+				if ($log_ids) {
189
+					$log_ids     = implode(',', array_map('intval', $log_ids));
190
+					$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);");
191 191
 
192
-					foreach ( $payment_ids as $payment_id ) {
193
-						$earnings += give_get_payment_amount( $payment_id );
192
+					foreach ($payment_ids as $payment_id) {
193
+						$earnings += give_get_payment_amount($payment_id);
194 194
 					}
195 195
 					
196 196
 				}
197 197
 
198 198
 				// Cache the results for one hour
199
-				set_transient( $key, $earnings, 60 * 60 );
199
+				set_transient($key, $earnings, 60 * 60);
200 200
 			}
201 201
 		}
202 202
 
203 203
 		//remove our filter
204
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
204
+		remove_filter('posts_where', array($this, 'payments_where'));
205 205
 
206 206
 		//return earnings
207
-		return round( $earnings, give_currency_decimal_filter() );
207
+		return round($earnings, give_currency_decimal_filter());
208 208
 
209 209
 	}
210 210
 
@@ -221,29 +221,29 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return float|int                Total amount of donations based on the passed arguments.
223 223
 	 */
224
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
224
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
225 225
 
226
-		$this->setup_dates( $start_date, $end_date );
226
+		$this->setup_dates($start_date, $end_date);
227 227
 
228 228
 		// Make sure start date is valid
229
-		if ( is_wp_error( $this->start_date ) ) {
229
+		if (is_wp_error($this->start_date)) {
230 230
 			return $this->start_date;
231 231
 		}
232 232
 
233 233
 		// Make sure end date is valid
234
-		if ( is_wp_error( $this->end_date ) ) {
234
+		if (is_wp_error($this->end_date)) {
235 235
 			return $this->end_date;
236 236
 		}
237 237
 
238
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
238
+		add_filter('posts_where', array($this, 'payments_where'));
239 239
 
240
-		if ( empty( $form_id ) ) {
240
+		if (empty($form_id)) {
241 241
 
242 242
 			// Global earning stats
243 243
 			$args = array(
244 244
 				'post_type'              => 'give_payment',
245 245
 				'nopaging'               => true,
246
-				'post_status'            => array( 'publish' ),
246
+				'post_status'            => array('publish'),
247 247
 				'fields'                 => 'ids',
248 248
 				'update_post_term_cache' => false,
249 249
 				'suppress_filters'       => false,
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 			);
256 256
 
257 257
 			//Filter by Gateway ID meta_key
258
-			if ( $gateway_id !== false ) {
258
+			if ($gateway_id !== false) {
259 259
 				$args['meta_key']   = '_give_payment_gateway';
260 260
 				$args['meta_value'] = $gateway_id;
261 261
 			}
262 262
 
263
-			$args = apply_filters( 'give_stats_earnings_args', $args );
264
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
263
+			$args = apply_filters('give_stats_earnings_args', $args);
264
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
265 265
 
266 266
 		} else {
267 267
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 				'give_transient_type' => 'give_earnings',
281 281
 				// This is not a valid query arg, but is used for cache keying
282 282
 			);
283
-			$args = apply_filters( 'give_stats_earnings_args', $args );
284
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
283
+			$args = apply_filters('give_stats_earnings_args', $args);
284
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
285 285
 		}
286 286
 
287 287
 		//remove our filter
288
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
288
+		remove_filter('posts_where', array($this, 'payments_where'));
289 289
 
290 290
 		//return earnings
291 291
 		return $key;
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return array       Best selling forms
304 304
 	 */
305
-	public function get_best_selling( $number = 10 ) {
305
+	public function get_best_selling($number = 10) {
306 306
 
307 307
 		global $wpdb;
308 308
 
309
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
309
+		$give_forms = $wpdb->get_results($wpdb->prepare(
310 310
 			"SELECT post_id as form_id, max(meta_value) as sales
311 311
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
312 312
 				GROUP BY meta_value+0
313 313
 				DESC LIMIT %d;", $number
314
-		) );
314
+		));
315 315
 
316 316
 		return $give_forms;
317 317
 	}
Please login to merge, or discard this patch.