Completed
Pull Request — master (#776)
by
unknown
18:12
created
includes/gateways/offline-donations.php 1 patch
Spacing   +122 added lines, -122 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_html( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_html( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_html('Offline Donation', 'give'),
25
+		'checkout_label' => esc_html('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_payment_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,56 +40,56 @@  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
 
54 54
 
55 55
 	ob_start(); ?>
56
-	<?php do_action( 'give_before_offline_info_fields', $form_id ); ?>
56
+	<?php do_action('give_before_offline_info_fields', $form_id); ?>
57 57
 	<fieldset id="give_offline_payment_info">
58 58
 		<?php
59
-		$settings_url         = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
59
+		$settings_url         = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
60 60
 		/* translators: %s: form settings url */
61
-		$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( esc_html( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
62
-		echo wpautop( stripslashes( $offline_instructions ) );
61
+		$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(esc_html('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
62
+		echo wpautop(stripslashes($offline_instructions));
63 63
 		?>
64 64
 	</fieldset>
65
-	<?php do_action( 'give_after_offline_info_fields', $form_id ); ?>
65
+	<?php do_action('give_after_offline_info_fields', $form_id); ?>
66 66
 	<?php
67 67
 	echo ob_get_clean();
68 68
 }
69 69
 
70
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
70
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
71 71
 
72 72
 /**
73 73
  * Give Offline Billing Field
74 74
  *
75 75
  * @param $form_id
76 76
  */
77
-function give_offline_billing_fields( $form_id ) {
77
+function give_offline_billing_fields($form_id) {
78 78
 	//Enable Default CC fields (billing info)
79
-	$post_offline_cc_fields        = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
80
-	$post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true );
79
+	$post_offline_cc_fields        = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
80
+	$post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true);
81 81
 
82
-	$global_offline_cc_fields      = give_get_option( 'give_offline_donation_enable_billing_fields' );
82
+	$global_offline_cc_fields      = give_get_option('give_offline_donation_enable_billing_fields');
83 83
 
84 84
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
85
-	if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) {
86
-		give_default_cc_address_fields( $form_id );
87
-	} elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') {
88
-		give_default_cc_address_fields( $form_id );
85
+	if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') {
86
+		give_default_cc_address_fields($form_id);
87
+	} elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') {
88
+		give_default_cc_address_fields($form_id);
89 89
 	}
90 90
 }
91 91
 
92
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
92
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
93 93
 
94 94
 /**
95 95
  * Process the payment
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  *
101 101
  * @return void
102 102
  */
103
-function give_offline_process_payment( $purchase_data ) {
103
+function give_offline_process_payment($purchase_data) {
104 104
 
105
-	$purchase_summary = give_get_purchase_summary( $purchase_data );
105
+	$purchase_summary = give_get_purchase_summary($purchase_data);
106 106
 
107 107
 	// setup the payment details
108 108
 	$payment_data = array(
109 109
 		'price'           => $purchase_data['price'],
110 110
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
111
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
112
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
111
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
112
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
113 113
 		'date'            => $purchase_data['date'],
114 114
 		'user_email'      => $purchase_data['user_email'],
115 115
 		'purchase_key'    => $purchase_data['purchase_key'],
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
 
122 122
 
123 123
 	// record the pending payment
124
-	$payment = give_insert_payment( $payment_data );
124
+	$payment = give_insert_payment($payment_data);
125 125
 
126
-	if ( $payment ) {
127
-		give_offline_send_admin_notice( $payment );
128
-		give_offline_send_donor_instructions( $payment );
126
+	if ($payment) {
127
+		give_offline_send_admin_notice($payment);
128
+		give_offline_send_donor_instructions($payment);
129 129
 		give_send_to_success_page();
130 130
 	} else {
131 131
 		// if errors are present, send the user back to the donation form so they can be corrected
132
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
132
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
133 133
 	}
134 134
 
135 135
 }
136 136
 
137
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
137
+add_action('give_gateway_offline', 'give_offline_process_payment');
138 138
 
139 139
 
140 140
 /**
@@ -147,47 +147,47 @@  discard block
 block discarded – undo
147 147
  * @since       1.0
148 148
  * @return void
149 149
  */
150
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
150
+function give_offline_send_donor_instructions($payment_id = 0) {
151 151
 
152
-	$payment_data                      = give_get_payment_meta( $payment_id );
153
-	$post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
152
+	$payment_data                      = give_get_payment_meta($payment_id);
153
+	$post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
154 154
 
155 155
 	//Customize email content depending on whether the single form has been customized
156
-	$email_content = give_get_option( 'global_offline_donation_email' );
156
+	$email_content = give_get_option('global_offline_donation_email');
157 157
 
158
-	if ( $post_offline_customization_option === 'yes' ) {
159
-		$email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
158
+	if ($post_offline_customization_option === 'yes') {
159
+		$email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true);
160 160
 	}
161 161
 
162
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
163
-	$from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data );
162
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
163
+	$from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
164 164
 
165
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
166
-	$from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data );
165
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
166
+	$from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
167 167
 
168
-	$to_email = give_get_payment_user_email( $payment_id );
168
+	$to_email = give_get_payment_user_email($payment_id);
169 169
 
170
-	$subject = give_get_option( 'offline_donation_subject', esc_html( 'Offline Donation Instructions', 'give' ) );
171
-	if ( $post_offline_customization_option === 'yes' ) {
172
-		$subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
170
+	$subject = give_get_option('offline_donation_subject', esc_html('Offline Donation Instructions', 'give'));
171
+	if ($post_offline_customization_option === 'yes') {
172
+		$subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
173 173
 	}
174 174
 
175
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
176
-	$subject = give_do_email_tags( $subject, $payment_id );
175
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
176
+	$subject = give_do_email_tags($subject, $payment_id);
177 177
 
178
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
179
-	$message     = give_do_email_tags( $email_content, $payment_id );
178
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
179
+	$message     = give_do_email_tags($email_content, $payment_id);
180 180
 
181 181
 	$emails = Give()->emails;
182 182
 
183
-	$emails->__set( 'from_name', $from_name );
184
-	$emails->__set( 'from_email', $from_email );
185
-	$emails->__set( 'heading', esc_html( 'Offline Donation Instructions', 'give' ) );
183
+	$emails->__set('from_name', $from_name);
184
+	$emails->__set('from_email', $from_email);
185
+	$emails->__set('heading', esc_html('Offline Donation Instructions', 'give'));
186 186
 
187
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
188
-	$emails->__set( 'headers', $headers );
187
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
188
+	$emails->__set('headers', $headers);
189 189
 
190
-	$emails->send( $to_email, $subject, $message, $attachments );
190
+	$emails->send($to_email, $subject, $message, $attachments);
191 191
 
192 192
 }
193 193
 
@@ -204,50 +204,50 @@  discard block
 block discarded – undo
204 204
  * @return void
205 205
  *
206 206
  */
207
-function give_offline_send_admin_notice( $payment_id = 0 ) {
207
+function give_offline_send_admin_notice($payment_id = 0) {
208 208
 
209 209
 	/* Send an email notification to the admin */
210 210
 	$admin_email = give_get_admin_notice_emails();
211
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
211
+	$user_info   = give_get_payment_meta_user_info($payment_id);
212 212
 
213
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
214
-		$user_data = get_userdata( $user_info['id'] );
213
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
214
+		$user_data = get_userdata($user_info['id']);
215 215
 		$name      = $user_data->display_name;
216
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
217
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
216
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
217
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
218 218
 	} else {
219 219
 		$name = $user_info['email'];
220 220
 	}
221 221
 
222
-	$amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) );
222
+	$amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)));
223 223
 
224
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_html( 'New Pending Donation', 'give' ), $payment_id );
224
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_html('New Pending Donation', 'give'), $payment_id);
225 225
 
226
-	$admin_message = esc_html( 'Dear Admin,', 'give' ) . "\n\n";
227
-	$admin_message .= esc_html( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' ';
228
-	$admin_message .= esc_html( '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";
226
+	$admin_message = esc_html('Dear Admin,', 'give')."\n\n";
227
+	$admin_message .= esc_html('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' ';
228
+	$admin_message .= esc_html('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";
229 229
 
230 230
 
231
-	$admin_message .= '<strong>' . esc_html( 'Donor: ', 'give' ) . '</strong>' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
232
-	$admin_message .= '<strong>' . esc_html( 'Amount: ', 'give' ) . '</strong>' . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n";
231
+	$admin_message .= '<strong>'.esc_html('Donor: ', 'give').'</strong>'.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
232
+	$admin_message .= '<strong>'.esc_html('Amount: ', 'give').'</strong>'.html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n";
233 233
 
234 234
 	$admin_message .= sprintf(
235 235
 		'<a href="%1$s">%2$s</a>',
236
-		admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ),
237
-		esc_html( 'Click Here to View and/or Update Donation Details', 'give' )
238
-	) . "\n\n";
236
+		admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id),
237
+		esc_html('Click Here to View and/or Update Donation Details', 'give')
238
+	)."\n\n";
239 239
 
240
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
241
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
242
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
240
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
241
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
242
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
243 243
 
244 244
 	//Send Email
245 245
 	$emails = Give()->emails;
246
-	if ( ! empty( $admin_headers ) ) {
247
-		$emails->__set( 'headers', $admin_headers );
246
+	if ( ! empty($admin_headers)) {
247
+		$emails->__set('headers', $admin_headers);
248 248
 	}
249 249
 
250
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
250
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
251 251
 
252 252
 }
253 253
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
  * @since  1.0
259 259
  * @return array
260 260
  */
261
-function give_offline_add_settings( $settings ) {
261
+function give_offline_add_settings($settings) {
262 262
 
263 263
 	//Vars
264 264
 	$prefix = '_give_';
265 265
 
266
-	$is_gateway_active = give_is_gateway_active( 'offline' );
266
+	$is_gateway_active = give_is_gateway_active('offline');
267 267
 
268 268
 	//this gateway isn't active
269
-	if ( ! $is_gateway_active ) {
269
+	if ( ! $is_gateway_active) {
270 270
 		//return settings and bounce
271 271
 		return $settings;
272 272
 	}
@@ -275,27 +275,27 @@  discard block
 block discarded – undo
275 275
 	$check_settings = array(
276 276
 
277 277
 		array(
278
-			'name'    => esc_html( 'Customize Offline Donations', 'give' ),
279
-			'desc'    => esc_html( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ),
280
-			'id'      => $prefix . 'customize_offline_donations',
278
+			'name'    => esc_html('Customize Offline Donations', 'give'),
279
+			'desc'    => esc_html('If you would like to customize the donation instructions for this specific forms check this option.', 'give'),
280
+			'id'      => $prefix.'customize_offline_donations',
281 281
 			'type'    => 'radio_inline',
282 282
 			'default' => 'no',
283 283
 			'options' => array(
284
-				'yes' => esc_html( 'Yes', 'give' ),
285
-				'no'  => esc_html( 'No', 'give' ),
284
+				'yes' => esc_html('Yes', 'give'),
285
+				'no'  => esc_html('No', 'give'),
286 286
 			),
287 287
 		),
288 288
 		array(
289
-			'name'        => esc_html( 'Request Billing Information', 'give' ),
290
-			'desc'        => esc_html( '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' ),
291
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
289
+			'name'        => esc_html('Request Billing Information', 'give'),
290
+			'desc'        => esc_html('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'),
291
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
292 292
 			'row_classes' => 'give-subfield',
293 293
 			'type'        => 'checkbox'
294 294
 		),
295 295
 		array(
296
-			'id'          => $prefix . 'offline_checkout_notes',
297
-			'name'        => esc_html( 'Offline Donation Instructions', 'give' ),
298
-			'desc'        => esc_html( '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' ),
296
+			'id'          => $prefix.'offline_checkout_notes',
297
+			'name'        => esc_html('Offline Donation Instructions', 'give'),
298
+			'desc'        => esc_html('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'),
299 299
 			'default'     => give_get_default_offline_donation_content(),
300 300
 			'type'        => 'wysiwyg',
301 301
 			'row_classes' => 'give-subfield',
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
 			)
305 305
 		),
306 306
 		array(
307
-			'id'          => $prefix . 'offline_donation_subject',
308
-			'name'        => esc_html( 'Offline Donation Email Instructions Subject', 'give' ),
309
-			'desc'        => esc_html( 'Enter the subject line for the donation receipt email.', 'give' ),
310
-			'default'     => esc_html( '{donation} - Offline Donation Instructions', 'give' ),
307
+			'id'          => $prefix.'offline_donation_subject',
308
+			'name'        => esc_html('Offline Donation Email Instructions Subject', 'give'),
309
+			'desc'        => esc_html('Enter the subject line for the donation receipt email.', 'give'),
310
+			'default'     => esc_html('{donation} - Offline Donation Instructions', 'give'),
311 311
 			'row_classes' => 'give-subfield',
312 312
 			'type'        => 'text'
313 313
 		),
314 314
 		array(
315
-			'id'          => $prefix . 'offline_donation_email',
316
-			'name'        => esc_html( 'Offline Donation Email Instructions', 'give' ),
317
-			'desc'        => esc_html( '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' ),
315
+			'id'          => $prefix.'offline_donation_email',
316
+			'name'        => esc_html('Offline Donation Email Instructions', 'give'),
317
+			'desc'        => esc_html('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'),
318 318
 			'default'     => give_get_default_offline_donation_email_content(),
319 319
 			'type'        => 'wysiwyg',
320 320
 			'row_classes' => 'give-subfield',
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 		)
325 325
 	);
326 326
 
327
-	return array_merge( $settings, $check_settings );
327
+	return array_merge($settings, $check_settings);
328 328
 }
329 329
 
330
-add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' );
330
+add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings');
331 331
 
332 332
 
333 333
 /**
@@ -339,32 +339,32 @@  discard block
 block discarded – undo
339 339
  */
340 340
 function give_get_default_offline_donation_content() {
341 341
 
342
-	$sitename = get_bloginfo( 'sitename' );
342
+	$sitename = get_bloginfo('sitename');
343 343
 
344
-	$default_text = '<p>' . esc_html( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
344
+	$default_text = '<p>'.esc_html('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
345 345
 	$default_text .= '<ol>';
346 346
 	$default_text .= '<li>';
347 347
 	$default_text .= sprintf(
348 348
 		/* translators: %s: site name */
349
-		esc_html( 'Make a check payable to "%s"', 'give' ),
349
+		esc_html('Make a check payable to "%s"', 'give'),
350 350
 		$sitename
351 351
 	);
352 352
 	$default_text .= '</li>';
353 353
 	$default_text .= '<li>';
354 354
 	$default_text .= sprintf(
355 355
 		/* translators: %s: site name */
356
-		esc_html( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
356
+		esc_html('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
357 357
 		$sitename
358 358
 	);
359 359
 	$default_text .= '</li>';
360
-	$default_text .= '<li>' . esc_html( 'Please mail your check to:', 'give' ) . '</li>';
360
+	$default_text .= '<li>'.esc_html('Please mail your check to:', 'give').'</li>';
361 361
 	$default_text .= '</ol>';
362
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
362
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
363 363
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
364 364
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
365
-	$default_text .= '<p>' . esc_html( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
365
+	$default_text .= '<p>'.esc_html('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
366 366
 
367
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
367
+	return apply_filters('give_default_offline_donation_content', $default_text);
368 368
 
369 369
 }
370 370
 
@@ -377,33 +377,33 @@  discard block
 block discarded – undo
377 377
  */
378 378
 function give_get_default_offline_donation_email_content() {
379 379
 
380
-	$sitename      = get_bloginfo( 'sitename' );
381
-	$default_text  = '<p>' . esc_html( 'Dear {name},', 'give' ) . '</p>';
382
-	$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>';
380
+	$sitename      = get_bloginfo('sitename');
381
+	$default_text  = '<p>'.esc_html('Dear {name},', 'give').'</p>';
382
+	$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>';
383 383
 	$default_text .= '<ol>';
384 384
 	$default_text .= '<li>';
385 385
 	$default_text .= sprintf(
386 386
 		/* translators: %s: site name */
387
-		esc_html( 'Make a check payable to "%s"', 'give' ),
387
+		esc_html('Make a check payable to "%s"', 'give'),
388 388
 		$sitename
389 389
 	);
390 390
 	$default_text .= '</li>';
391 391
 	$default_text .= '<li>';
392 392
 	$default_text .= sprintf(
393 393
 		/* translators: %s: site name */
394
-		esc_html( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
394
+		esc_html('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
395 395
 		$sitename
396 396
 	);
397 397
 	$default_text .= '</li>';
398
-	$default_text .= '<li>' . esc_html( 'Please mail your check to:', 'give' ) . '</li>';
398
+	$default_text .= '<li>'.esc_html('Please mail your check to:', 'give').'</li>';
399 399
 	$default_text .= '</ol>';
400
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
400
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
401 401
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
402 402
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
403
-	$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>';
404
-	$default_text .= '<p>' . esc_html( 'Sincerely,', 'give' ) . '</p>';
405
-	$default_text .= '<p>' . $sitename . '</p>';
403
+	$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>';
404
+	$default_text .= '<p>'.esc_html('Sincerely,', 'give').'</p>';
405
+	$default_text .= '<p>'.$sitename.'</p>';
406 406
 
407
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
407
+	return apply_filters('give_default_offline_donation_content', $default_text);
408 408
 
409 409
 }
Please login to merge, or discard this patch.
includes/api/class-give-api.php 1 patch
Spacing   +482 added lines, -482 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
 
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('wp', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Setup a backwards compatibility check for user API Keys
156
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
156
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
157 157
 
158 158
 		// Determine if JSON_PRETTY_PRINT is available
159
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
159
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
160 160
 
161 161
 		// Allow API request logging to be turned off
162
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
162
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
163 163
 
164 164
 		// Setup Give_Payment_Stats instance
165 165
 		$this->stats = new Give_Payment_Stats;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @since  1.1
177 177
 	 */
178
-	public function add_endpoint( $rewrite_rules ) {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
178
+	public function add_endpoint($rewrite_rules) {
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_html( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = esc_html('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_html( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = esc_html('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_html( 'Invalid API key!', 'give' );
460
+		$error['error'] = esc_html('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_html( 'Invalid API version!', 'give' );
476
+		$error['error'] = esc_html('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations'
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = esc_html( 'Invalid query!', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = esc_html('Invalid query!', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			// 400 is Bad Request
618
-			$this->output( 400 );
618
+			$this->output(400);
619 619
 		}
620 620
 
621 621
 		$this->endpoint = $query;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	public function get_paged() {
633 633
 		global $wp_query;
634 634
 
635
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
635
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
636 636
 	}
637 637
 
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	public function per_page() {
648 648
 		global $wp_query;
649 649
 
650
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
650
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
651 651
 
652
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
652
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
653 653
 			$per_page = 99999999;
654 654
 		} // Customers query doesn't support -1
655 655
 
656
-		return apply_filters( 'give_api_results_per_page', $per_page );
656
+		return apply_filters('give_api_results_per_page', $per_page);
657 657
 	}
658 658
 
659 659
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return array $dates
668 668
 	 */
669
-	public function get_dates( $args = array() ) {
669
+	public function get_dates($args = array()) {
670 670
 		$dates = array();
671 671
 
672 672
 		$defaults = array(
@@ -677,60 +677,60 @@  discard block
 block discarded – undo
677 677
 			'enddate'   => null
678 678
 		);
679 679
 
680
-		$args = wp_parse_args( $args, $defaults );
680
+		$args = wp_parse_args($args, $defaults);
681 681
 
682
-		$current_time = current_time( 'timestamp' );
682
+		$current_time = current_time('timestamp');
683 683
 
684
-		if ( 'range' === $args['date'] ) {
685
-			$startdate          = strtotime( $args['startdate'] );
686
-			$enddate            = strtotime( $args['enddate'] );
687
-			$dates['day_start'] = date( 'd', $startdate );
688
-			$dates['day_end']   = date( 'd', $enddate );
689
-			$dates['m_start']   = date( 'n', $startdate );
690
-			$dates['m_end']     = date( 'n', $enddate );
691
-			$dates['year']      = date( 'Y', $startdate );
692
-			$dates['year_end']  = date( 'Y', $enddate );
684
+		if ('range' === $args['date']) {
685
+			$startdate          = strtotime($args['startdate']);
686
+			$enddate            = strtotime($args['enddate']);
687
+			$dates['day_start'] = date('d', $startdate);
688
+			$dates['day_end']   = date('d', $enddate);
689
+			$dates['m_start']   = date('n', $startdate);
690
+			$dates['m_end']     = date('n', $enddate);
691
+			$dates['year']      = date('Y', $startdate);
692
+			$dates['year_end']  = date('Y', $enddate);
693 693
 		} else {
694 694
 			// Modify dates based on predefined ranges
695
-			switch ( $args['date'] ) :
695
+			switch ($args['date']) :
696 696
 
697 697
 				case 'this_month' :
698 698
 					$dates['day']     = null;
699
-					$dates['m_start'] = date( 'n', $current_time );
700
-					$dates['m_end']   = date( 'n', $current_time );
701
-					$dates['year']    = date( 'Y', $current_time );
699
+					$dates['m_start'] = date('n', $current_time);
700
+					$dates['m_end']   = date('n', $current_time);
701
+					$dates['year']    = date('Y', $current_time);
702 702
 					break;
703 703
 
704 704
 				case 'last_month' :
705 705
 					$dates['day']     = null;
706
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
706
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
707 707
 					$dates['m_end']   = $dates['m_start'];
708
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
708
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
709 709
 					break;
710 710
 
711 711
 				case 'today' :
712
-					$dates['day']     = date( 'd', $current_time );
713
-					$dates['m_start'] = date( 'n', $current_time );
714
-					$dates['m_end']   = date( 'n', $current_time );
715
-					$dates['year']    = date( 'Y', $current_time );
712
+					$dates['day']     = date('d', $current_time);
713
+					$dates['m_start'] = date('n', $current_time);
714
+					$dates['m_end']   = date('n', $current_time);
715
+					$dates['year']    = date('Y', $current_time);
716 716
 					break;
717 717
 
718 718
 				case 'yesterday' :
719 719
 
720
-					$year  = date( 'Y', $current_time );
721
-					$month = date( 'n', $current_time );
722
-					$day   = date( 'd', $current_time );
720
+					$year  = date('Y', $current_time);
721
+					$month = date('n', $current_time);
722
+					$day   = date('d', $current_time);
723 723
 
724
-					if ( $month == 1 && $day == 1 ) {
724
+					if ($month == 1 && $day == 1) {
725 725
 
726 726
 						$year -= 1;
727 727
 						$month = 12;
728
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
728
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
729 729
 
730
-					} elseif ( $month > 1 && $day == 1 ) {
730
+					} elseif ($month > 1 && $day == 1) {
731 731
 
732 732
 						$month -= 1;
733
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
733
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
734 734
 
735 735
 					} else {
736 736
 
@@ -746,65 +746,65 @@  discard block
 block discarded – undo
746 746
 					break;
747 747
 
748 748
 				case 'this_quarter' :
749
-					$month_now = date( 'n', $current_time );
749
+					$month_now = date('n', $current_time);
750 750
 
751 751
 					$dates['day'] = null;
752 752
 
753
-					if ( $month_now <= 3 ) {
753
+					if ($month_now <= 3) {
754 754
 
755 755
 						$dates['m_start'] = 1;
756 756
 						$dates['m_end']   = 3;
757
-						$dates['year']    = date( 'Y', $current_time );
757
+						$dates['year']    = date('Y', $current_time);
758 758
 
759
-					} else if ( $month_now <= 6 ) {
759
+					} else if ($month_now <= 6) {
760 760
 
761 761
 						$dates['m_start'] = 4;
762 762
 						$dates['m_end']   = 6;
763
-						$dates['year']    = date( 'Y', $current_time );
763
+						$dates['year']    = date('Y', $current_time);
764 764
 
765
-					} else if ( $month_now <= 9 ) {
765
+					} else if ($month_now <= 9) {
766 766
 
767 767
 						$dates['m_start'] = 7;
768 768
 						$dates['m_end']   = 9;
769
-						$dates['year']    = date( 'Y', $current_time );
769
+						$dates['year']    = date('Y', $current_time);
770 770
 
771 771
 					} else {
772 772
 
773 773
 						$dates['m_start'] = 10;
774 774
 						$dates['m_end']   = 12;
775
-						$dates['year']    = date( 'Y', $current_time );
775
+						$dates['year']    = date('Y', $current_time);
776 776
 
777 777
 					}
778 778
 					break;
779 779
 
780 780
 				case 'last_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 10;
788 788
 						$dates['m_end']   = 12;
789
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
789
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
790 790
 
791
-					} else if ( $month_now <= 6 ) {
791
+					} else if ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 1;
794 794
 						$dates['m_end']   = 3;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} else if ( $month_now <= 9 ) {
797
+					} else if ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 4;
800 800
 						$dates['m_end']   = 6;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 7;
806 806
 						$dates['m_end']   = 9;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 					$dates['day']     = null;
814 814
 					$dates['m_start'] = null;
815 815
 					$dates['m_end']   = null;
816
-					$dates['year']    = date( 'Y', $current_time );
816
+					$dates['year']    = date('Y', $current_time);
817 817
 					break;
818 818
 
819 819
 				case 'last_year' :
820 820
 					$dates['day']     = null;
821 821
 					$dates['m_start'] = null;
822 822
 					$dates['m_end']   = null;
823
-					$dates['year']    = date( 'Y', $current_time ) - 1;
823
+					$dates['year']    = date('Y', $current_time) - 1;
824 824
 					break;
825 825
 
826 826
 			endswitch;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		 * @param object $dates The dates used for retreiving earnings/donations
835 835
 		 */
836 836
 
837
-		return apply_filters( 'give_api_stat_dates', $dates );
837
+		return apply_filters('give_api_stat_dates', $dates);
838 838
 	}
839 839
 
840 840
 	/**
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return array $customers Multidimensional array of the customers
851 851
 	 */
852
-	public function get_customers( $customer = null ) {
852
+	public function get_customers($customer = null) {
853 853
 
854 854
 		$customers = array();
855 855
 		$error     = array();
856
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
856
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
857 857
 			return $customers;
858 858
 		}
859 859
 
@@ -861,64 +861,64 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$paged    = $this->get_paged();
863 863
 		$per_page = $this->per_page();
864
-		$offset   = $per_page * ( $paged - 1 );
864
+		$offset   = $per_page * ($paged - 1);
865 865
 
866
-		if ( is_numeric( $customer ) ) {
866
+		if (is_numeric($customer)) {
867 867
 			$field = 'id';
868 868
 		} else {
869 869
 			$field = 'email';
870 870
 		}
871 871
 
872
-		$customer_query = Give()->customers->get_customers( array(
872
+		$customer_query = Give()->customers->get_customers(array(
873 873
 			'number' => $per_page,
874 874
 			'offset' => $offset,
875 875
 			$field   => $customer
876
-		) );
876
+		));
877 877
 		$customer_count = 0;
878 878
 
879
-		if ( $customer_query ) {
879
+		if ($customer_query) {
880 880
 
881
-			foreach ( $customer_query as $customer_obj ) {
881
+			foreach ($customer_query as $customer_obj) {
882 882
 
883
-				$names      = explode( ' ', $customer_obj->name );
884
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
883
+				$names      = explode(' ', $customer_obj->name);
884
+				$first_name = ! empty($names[0]) ? $names[0] : '';
885 885
 				$last_name  = '';
886
-				if ( ! empty( $names[1] ) ) {
887
-					unset( $names[0] );
888
-					$last_name = implode( ' ', $names );
886
+				if ( ! empty($names[1])) {
887
+					unset($names[0]);
888
+					$last_name = implode(' ', $names);
889 889
 				}
890 890
 
891
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
892
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
893
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
894
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
895
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
896
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
897
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
891
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
892
+				$customers['donors'][$customer_count]['info']['username']     = '';
893
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
894
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
895
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
896
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
897
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
898 898
 
899
-				if ( ! empty( $customer_obj->user_id ) ) {
899
+				if ( ! empty($customer_obj->user_id)) {
900 900
 
901
-					$user_data = get_userdata( $customer_obj->user_id );
901
+					$user_data = get_userdata($customer_obj->user_id);
902 902
 
903 903
 					// Customer with registered account
904
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
905
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
906
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
904
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
905
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
906
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
907 907
 
908 908
 				}
909 909
 
910
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
911
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
910
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
911
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
912 912
 
913
-				$customer_count ++;
913
+				$customer_count++;
914 914
 
915 915
 			}
916 916
 
917
-		} elseif ( $customer ) {
917
+		} elseif ($customer) {
918 918
 
919 919
 			$error['error'] = sprintf(
920 920
 				/* translators: %s: customer */
921
-				esc_html( 'Donor %s not found!', 'give' ),
921
+				esc_html('Donor %s not found!', 'give'),
922 922
 				$customer
923 923
 			);
924 924
 
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 
927 927
 		} else {
928 928
 
929
-			$error['error'] = esc_html( 'No donors found!', 'give' );
929
+			$error['error'] = esc_html('No donors found!', 'give');
930 930
 
931 931
 			return $error;
932 932
 
@@ -945,38 +945,38 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return array $customers Multidimensional array of the forms
947 947
 	 */
948
-	public function get_forms( $form = null ) {
948
+	public function get_forms($form = null) {
949 949
 
950 950
 		$forms = array();
951 951
 		$error = array();
952 952
 
953
-		if ( $form == null ) {
953
+		if ($form == null) {
954 954
 			$forms['forms'] = array();
955 955
 
956
-			$form_list = get_posts( array(
956
+			$form_list = get_posts(array(
957 957
 				'post_type'        => 'give_forms',
958 958
 				'posts_per_page'   => $this->per_page(),
959 959
 				'suppress_filters' => true,
960 960
 				'paged'            => $this->get_paged()
961
-			) );
961
+			));
962 962
 
963
-			if ( $form_list ) {
963
+			if ($form_list) {
964 964
 				$i = 0;
965
-				foreach ( $form_list as $form_info ) {
966
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
967
-					$i ++;
965
+				foreach ($form_list as $form_info) {
966
+					$forms['forms'][$i] = $this->get_form_data($form_info);
967
+					$i++;
968 968
 				}
969 969
 			}
970 970
 		} else {
971
-			if ( get_post_type( $form ) == 'give_forms' ) {
972
-				$form_info = get_post( $form );
971
+			if (get_post_type($form) == 'give_forms') {
972
+				$form_info = get_post($form);
973 973
 
974
-				$forms['forms'][0] = $this->get_form_data( $form_info );
974
+				$forms['forms'][0] = $this->get_form_data($form_info);
975 975
 
976 976
 			} else {
977 977
 				$error['error'] = sprintf(
978 978
 					/* translators: %s: form */
979
-					esc_html( 'Form %s not found!', 'give' ),
979
+					esc_html('Form %s not found!', 'give'),
980 980
 					$form
981 981
 				);
982 982
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 	 *
997 997
 	 * @return array                Array of post data to return back in the API
998 998
 	 */
999
-	private function get_form_data( $form_info ) {
999
+	private function get_form_data($form_info) {
1000 1000
 
1001 1001
 		$form = array();
1002 1002
 
@@ -1006,46 +1006,46 @@  discard block
 block discarded – undo
1006 1006
 		$form['info']['create_date']   = $form_info->post_date;
1007 1007
 		$form['info']['modified_date'] = $form_info->post_modified;
1008 1008
 		$form['info']['status']        = $form_info->post_status;
1009
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1010
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1011
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1009
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1010
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1011
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1012 1012
 
1013
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1014
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1015
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1013
+		if (give_get_option('enable_categories') == 'on') {
1014
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1015
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1016 1016
 		}
1017
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1018
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1017
+		if (give_get_option('enable_tags') == 'on') {
1018
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1019 1019
 		}
1020 1020
 
1021
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1022
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1023
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1024
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1025
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1021
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1022
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1023
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1024
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1025
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1026 1026
 		}
1027 1027
 
1028 1028
 		$counter = 0;
1029
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1030
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1031
-				$counter ++;
1029
+		if (give_has_variable_prices($form_info->ID)) {
1030
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1031
+				$counter++;
1032 1032
 				//muli-level item
1033
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1034
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1033
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1034
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1035 1035
 
1036 1036
 			}
1037 1037
 		} else {
1038
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1038
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1039 1039
 		}
1040 1040
 
1041
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1041
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1042 1042
 
1043 1043
 			//Sensitive data here
1044
-			do_action( 'give_api_sensitive_data' );
1044
+			do_action('give_api_sensitive_data');
1045 1045
 
1046 1046
 		}
1047 1047
 
1048
-		return apply_filters( 'give_api_forms_form', $form );
1048
+		return apply_filters('give_api_forms_form', $form);
1049 1049
 
1050 1050
 	}
1051 1051
 
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 *
1061 1061
 	 * @return array
1062 1062
 	 */
1063
-	public function get_stats( $args = array() ) {
1063
+	public function get_stats($args = array()) {
1064 1064
 		$defaults = array(
1065 1065
 			'type'      => null,
1066 1066
 			'form'      => null,
@@ -1069,9 +1069,9 @@  discard block
 block discarded – undo
1069 1069
 			'enddate'   => null
1070 1070
 		);
1071 1071
 
1072
-		$args = wp_parse_args( $args, $defaults );
1072
+		$args = wp_parse_args($args, $defaults);
1073 1073
 
1074
-		$dates = $this->get_dates( $args );
1074
+		$dates = $this->get_dates($args);
1075 1075
 
1076 1076
 		$stats    = array();
1077 1077
 		$earnings = array(
@@ -1082,41 +1082,41 @@  discard block
 block discarded – undo
1082 1082
 		);
1083 1083
 		$error    = array();
1084 1084
 
1085
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1085
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1086 1086
 			return $stats;
1087 1087
 		}
1088 1088
 
1089
-		if ( $args['type'] == 'donations' ) {
1089
+		if ($args['type'] == 'donations') {
1090 1090
 
1091
-			if ( $args['form'] == null ) {
1092
-				if ( $args['date'] == null ) {
1091
+			if ($args['form'] == null) {
1092
+				if ($args['date'] == null) {
1093 1093
 					$sales = $this->get_default_sales_stats();
1094
-				} elseif ( $args['date'] === 'range' ) {
1094
+				} elseif ($args['date'] === 'range') {
1095 1095
 					// Return sales for a date range
1096 1096
 
1097 1097
 					// Ensure the end date is later than the start date
1098
-					if ( $args['enddate'] < $args['startdate'] ) {
1099
-						$error['error'] = esc_html( 'The end date must be later than the start date!', 'give' );
1098
+					if ($args['enddate'] < $args['startdate']) {
1099
+						$error['error'] = esc_html('The end date must be later than the start date!', 'give');
1100 1100
 					}
1101 1101
 
1102 1102
 					// Ensure both the start and end date are specified
1103
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1104
-						$error['error'] = esc_html( 'Invalid or no date range specified!', 'give' );
1103
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1104
+						$error['error'] = esc_html('Invalid or no date range specified!', 'give');
1105 1105
 					}
1106 1106
 
1107 1107
 					$total = 0;
1108 1108
 
1109 1109
 					// Loop through the years
1110 1110
 					$y = $dates['year'];
1111
-					while ( $y <= $dates['year_end'] ) :
1111
+					while ($y <= $dates['year_end']) :
1112 1112
 
1113
-						if ( $dates['year'] == $dates['year_end'] ) {
1113
+						if ($dates['year'] == $dates['year_end']) {
1114 1114
 							$month_start = $dates['m_start'];
1115 1115
 							$month_end   = $dates['m_end'];
1116
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1116
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1117 1117
 							$month_start = $dates['m_start'];
1118 1118
 							$month_end   = 12;
1119
-						} elseif ( $y == $dates['year_end'] ) {
1119
+						} elseif ($y == $dates['year_end']) {
1120 1120
 							$month_start = 1;
1121 1121
 							$month_end   = $dates['m_end'];
1122 1122
 						} else {
@@ -1125,113 +1125,113 @@  discard block
 block discarded – undo
1125 1125
 						}
1126 1126
 
1127 1127
 						$i = $month_start;
1128
-						while ( $i <= $month_end ) :
1128
+						while ($i <= $month_end) :
1129 1129
 
1130
-							if ( $i == $dates['m_start'] ) {
1130
+							if ($i == $dates['m_start']) {
1131 1131
 								$d = $dates['day_start'];
1132 1132
 							} else {
1133 1133
 								$d = 1;
1134 1134
 							}
1135 1135
 
1136
-							if ( $i == $dates['m_end'] ) {
1136
+							if ($i == $dates['m_end']) {
1137 1137
 								$num_of_days = $dates['day_end'];
1138 1138
 							} else {
1139
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1139
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1140 1140
 							}
1141 1141
 
1142
-							while ( $d <= $num_of_days ) :
1143
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1144
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1145
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1146
-									$sales['sales'][ $date_key ] = 0;
1142
+							while ($d <= $num_of_days) :
1143
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1144
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1145
+								if ( ! isset($sales['sales'][$date_key])) {
1146
+									$sales['sales'][$date_key] = 0;
1147 1147
 								}
1148
-								$sales['sales'][ $date_key ] += $sale_count;
1148
+								$sales['sales'][$date_key] += $sale_count;
1149 1149
 								$total += $sale_count;
1150
-								$d ++;
1150
+								$d++;
1151 1151
 							endwhile;
1152
-							$i ++;
1152
+							$i++;
1153 1153
 						endwhile;
1154 1154
 
1155
-						$y ++;
1155
+						$y++;
1156 1156
 					endwhile;
1157 1157
 
1158 1158
 					$sales['totals'] = $total;
1159 1159
 				} else {
1160
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1160
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1161 1161
 						$sales_count = 0;
1162 1162
 
1163 1163
 						// Loop through the months
1164 1164
 						$month = $dates['m_start'];
1165 1165
 
1166
-						while ( $month <= $dates['m_end'] ) :
1167
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1168
-							$month ++;
1166
+						while ($month <= $dates['m_end']) :
1167
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1168
+							$month++;
1169 1169
 						endwhile;
1170 1170
 
1171
-						$sales['donations'][ $args['date'] ] = $sales_count;
1171
+						$sales['donations'][$args['date']] = $sales_count;
1172 1172
 					} else {
1173
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1173
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1174 1174
 					}
1175 1175
 				}
1176
-			} elseif ( $args['form'] == 'all' ) {
1177
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1176
+			} elseif ($args['form'] == 'all') {
1177
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1178 1178
 				$i     = 0;
1179
-				foreach ( $forms as $form_info ) {
1180
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1181
-					$i ++;
1179
+				foreach ($forms as $form_info) {
1180
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1181
+					$i++;
1182 1182
 				}
1183 1183
 			} else {
1184
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1185
-					$form_info             = get_post( $args['form'] );
1186
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1184
+				if (get_post_type($args['form']) == 'give_forms') {
1185
+					$form_info             = get_post($args['form']);
1186
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1187 1187
 				} else {
1188 1188
 					$error['error'] = sprintf(
1189 1189
 						/* translators: %s: form */
1190
-						esc_html( 'Product %s not found!', 'give' ),
1190
+						esc_html('Product %s not found!', 'give'),
1191 1191
 						$args['form']
1192 1192
 					);
1193 1193
 				}
1194 1194
 			}
1195 1195
 
1196
-			if ( ! empty( $error ) ) {
1196
+			if ( ! empty($error)) {
1197 1197
 				return $error;
1198 1198
 			}
1199 1199
 
1200 1200
 			return $sales;
1201 1201
 
1202
-		} elseif ( $args['type'] == 'earnings' ) {
1203
-			if ( $args['form'] == null ) {
1204
-				if ( $args['date'] == null ) {
1202
+		} elseif ($args['type'] == 'earnings') {
1203
+			if ($args['form'] == null) {
1204
+				if ($args['date'] == null) {
1205 1205
 					$earnings = $this->get_default_earnings_stats();
1206
-				} elseif ( $args['date'] === 'range' ) {
1206
+				} elseif ($args['date'] === 'range') {
1207 1207
 					// Return sales for a date range
1208 1208
 
1209 1209
 					// Ensure the end date is later than the start date
1210
-					if ( $args['enddate'] < $args['startdate'] ) {
1211
-						$error['error'] = esc_html( 'The end date must be later than the start date!', 'give' );
1210
+					if ($args['enddate'] < $args['startdate']) {
1211
+						$error['error'] = esc_html('The end date must be later than the start date!', 'give');
1212 1212
 					}
1213 1213
 
1214 1214
 					// Ensure both the start and end date are specified
1215
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1216
-						$error['error'] = esc_html( 'Invalid or no date range specified!', 'give' );
1215
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1216
+						$error['error'] = esc_html('Invalid or no date range specified!', 'give');
1217 1217
 					}
1218 1218
 
1219 1219
 					$total = (float) 0.00;
1220 1220
 
1221 1221
 					// Loop through the years
1222 1222
 					$y = $dates['year'];
1223
-					if ( ! isset( $earnings['earnings'] ) ) {
1223
+					if ( ! isset($earnings['earnings'])) {
1224 1224
 						$earnings['earnings'] = array();
1225 1225
 					}
1226
-					while ( $y <= $dates['year_end'] ) :
1226
+					while ($y <= $dates['year_end']) :
1227 1227
 
1228
-						if ( $dates['year'] == $dates['year_end'] ) {
1228
+						if ($dates['year'] == $dates['year_end']) {
1229 1229
 							$month_start = $dates['m_start'];
1230 1230
 							$month_end   = $dates['m_end'];
1231
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1231
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1232 1232
 							$month_start = $dates['m_start'];
1233 1233
 							$month_end   = 12;
1234
-						} elseif ( $y == $dates['year_end'] ) {
1234
+						} elseif ($y == $dates['year_end']) {
1235 1235
 							$month_start = 1;
1236 1236
 							$month_end   = $dates['m_end'];
1237 1237
 						} else {
@@ -1240,92 +1240,92 @@  discard block
 block discarded – undo
1240 1240
 						}
1241 1241
 
1242 1242
 						$i = $month_start;
1243
-						while ( $i <= $month_end ) :
1243
+						while ($i <= $month_end) :
1244 1244
 
1245
-							if ( $i == $dates['m_start'] ) {
1245
+							if ($i == $dates['m_start']) {
1246 1246
 								$d = $dates['day_start'];
1247 1247
 							} else {
1248 1248
 								$d = 1;
1249 1249
 							}
1250 1250
 
1251
-							if ( $i == $dates['m_end'] ) {
1251
+							if ($i == $dates['m_end']) {
1252 1252
 								$num_of_days = $dates['day_end'];
1253 1253
 							} else {
1254
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1254
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1255 1255
 							}
1256 1256
 
1257
-							while ( $d <= $num_of_days ) :
1258
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1259
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1260
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1261
-									$earnings['earnings'][ $date_key ] = 0;
1257
+							while ($d <= $num_of_days) :
1258
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1259
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1260
+								if ( ! isset($earnings['earnings'][$date_key])) {
1261
+									$earnings['earnings'][$date_key] = 0;
1262 1262
 								}
1263
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1263
+								$earnings['earnings'][$date_key] += $earnings_stat;
1264 1264
 								$total += $earnings_stat;
1265
-								$d ++;
1265
+								$d++;
1266 1266
 							endwhile;
1267 1267
 
1268
-							$i ++;
1268
+							$i++;
1269 1269
 						endwhile;
1270 1270
 
1271
-						$y ++;
1271
+						$y++;
1272 1272
 					endwhile;
1273 1273
 
1274 1274
 					$earnings['totals'] = $total;
1275 1275
 				} else {
1276
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1276
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1277 1277
 						$earnings_count = (float) 0.00;
1278 1278
 
1279 1279
 						// Loop through the months
1280 1280
 						$month = $dates['m_start'];
1281 1281
 
1282
-						while ( $month <= $dates['m_end'] ) :
1283
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1284
-							$month ++;
1282
+						while ($month <= $dates['m_end']) :
1283
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1284
+							$month++;
1285 1285
 						endwhile;
1286 1286
 
1287
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1287
+						$earnings['earnings'][$args['date']] = $earnings_count;
1288 1288
 					} else {
1289
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1289
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1290 1290
 					}
1291 1291
 				}
1292
-			} elseif ( $args['form'] == 'all' ) {
1293
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1292
+			} elseif ($args['form'] == 'all') {
1293
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1294 1294
 
1295 1295
 				$i = 0;
1296
-				foreach ( $forms as $form_info ) {
1297
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1298
-					$i ++;
1296
+				foreach ($forms as $form_info) {
1297
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1298
+					$i++;
1299 1299
 				}
1300 1300
 			} else {
1301
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1302
-					$form_info               = get_post( $args['form'] );
1303
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1301
+				if (get_post_type($args['form']) == 'give_forms') {
1302
+					$form_info               = get_post($args['form']);
1303
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1304 1304
 				} else {
1305 1305
 					$error['error'] = sprintf(
1306 1306
 						/* translators: %s: form */
1307
-						esc_html( 'Form %s not found!', 'give' ),
1307
+						esc_html('Form %s not found!', 'give'),
1308 1308
 						$args['form']
1309 1309
 					);
1310 1310
 				}
1311 1311
 			}
1312 1312
 
1313
-			if ( ! empty( $error ) ) {
1313
+			if ( ! empty($error)) {
1314 1314
 				return $error;
1315 1315
 			}
1316 1316
 
1317 1317
 			return $earnings;
1318
-		} elseif ( $args['type'] == 'donors' ) {
1318
+		} elseif ($args['type'] == 'donors') {
1319 1319
 			$customers                          = new Give_DB_Customers();
1320 1320
 			$stats['donations']['total_donors'] = $customers->count();
1321 1321
 
1322 1322
 			return $stats;
1323 1323
 
1324
-		} elseif ( empty( $args['type'] ) ) {
1325
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1326
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1324
+		} elseif (empty($args['type'])) {
1325
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1326
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1327 1327
 
1328
-			return array( 'stats' => $stats );
1328
+			return array('stats' => $stats);
1329 1329
 		}
1330 1330
 	}
1331 1331
 
@@ -1341,18 +1341,18 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
 		$sales = array();
1343 1343
 
1344
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1344
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1345 1345
 			return $sales;
1346 1346
 		}
1347 1347
 
1348
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1348
+		if (isset($wp_query->query_vars['id'])) {
1349 1349
 			$query   = array();
1350
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1351
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1350
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1351
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1352 1352
 			$query   = array();
1353
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1354
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1355
-			$args  = array(
1353
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1354
+		} elseif (isset($wp_query->query_vars['email'])) {
1355
+			$args = array(
1356 1356
 				'fields'     => 'ids',
1357 1357
 				'meta_key'   => '_give_payment_user_email',
1358 1358
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 				'page'       => $this->get_paged(),
1361 1361
 				'status'     => 'publish'
1362 1362
 			);
1363
-			$query = give_get_payments( $args );
1363
+			$query = give_get_payments($args);
1364 1364
 		} else {
1365 1365
 			$args  = array(
1366 1366
 				'fields' => 'ids',
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 				'page'   => $this->get_paged(),
1369 1369
 				'status' => 'publish'
1370 1370
 			);
1371
-			$query = give_get_payments( $args );
1371
+			$query = give_get_payments($args);
1372 1372
 		}
1373
-		if ( $query ) {
1373
+		if ($query) {
1374 1374
 			$i = 0;
1375
-			foreach ( $query as $payment ) {
1375
+			foreach ($query as $payment) {
1376 1376
 
1377
-				if ( is_numeric( $payment ) ) {
1378
-					$payment      = new Give_Payment( $payment );
1377
+				if (is_numeric($payment)) {
1378
+					$payment      = new Give_Payment($payment);
1379 1379
 					$payment_meta = $payment->get_meta();
1380 1380
 					$user_info    = $payment->user_info;
1381 1381
 				} else {
@@ -1385,40 +1385,40 @@  discard block
 block discarded – undo
1385 1385
 				$payment_meta = $payment->get_meta();
1386 1386
 				$user_info    = $payment->user_info;
1387 1387
 
1388
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1389
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1390
-
1391
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1392
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1393
-				$sales['donations'][ $i ]['key']            = $payment->key;
1394
-				$sales['donations'][ $i ]['total']          = $payment->total;
1395
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1396
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1397
-				$sales['donations'][ $i ]['fname']          = $first_name;
1398
-				$sales['donations'][ $i ]['lname']          = $last_name;
1399
-				$sales['donations'][ $i ]['email']          = $payment->email;
1400
-				$sales['donations'][ $i ]['date']           = $payment->date;
1401
-
1402
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1403
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1404
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1405
-
1406
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1407
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1408
-				$sales['donations'][ $i ]['form']['price'] = $price;
1409
-
1410
-				if ( give_has_variable_prices( $form_id ) ) {
1411
-					if ( isset( $payment_meta['price_id'] ) ) {
1412
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1413
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1414
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1415
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1388
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1389
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1390
+
1391
+				$sales['donations'][$i]['ID']             = $payment->number;
1392
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1393
+				$sales['donations'][$i]['key']            = $payment->key;
1394
+				$sales['donations'][$i]['total']          = $payment->total;
1395
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1396
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1397
+				$sales['donations'][$i]['fname']          = $first_name;
1398
+				$sales['donations'][$i]['lname']          = $last_name;
1399
+				$sales['donations'][$i]['email']          = $payment->email;
1400
+				$sales['donations'][$i]['date']           = $payment->date;
1401
+
1402
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1403
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1404
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1405
+
1406
+				$sales['donations'][$i]['form']['id']    = $form_id;
1407
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1408
+				$sales['donations'][$i]['form']['price'] = $price;
1409
+
1410
+				if (give_has_variable_prices($form_id)) {
1411
+					if (isset($payment_meta['price_id'])) {
1412
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1413
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1414
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1415
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1416 1416
 
1417 1417
 					}
1418 1418
 				}
1419 1419
 
1420 1420
 				//Add custom meta to API
1421
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1421
+				foreach ($payment_meta as $meta_key => $meta_value) {
1422 1422
 
1423 1423
 					$exceptions = array(
1424 1424
 						'form_title',
@@ -1431,19 +1431,19 @@  discard block
 block discarded – undo
1431 1431
 					);
1432 1432
 
1433 1433
 					//Don't clutter up results with dupes
1434
-					if ( in_array( $meta_key, $exceptions ) ) {
1434
+					if (in_array($meta_key, $exceptions)) {
1435 1435
 						continue;
1436 1436
 					}
1437 1437
 
1438
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1438
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1439 1439
 
1440 1440
 				}
1441 1441
 
1442
-				$i ++;
1442
+				$i++;
1443 1443
 			}
1444 1444
 		}
1445 1445
 
1446
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1446
+		return apply_filters('give_api_donations_endpoint', $sales);
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1458,9 +1458,9 @@  discard block
 block discarded – undo
1458 1458
 	public function get_output_format() {
1459 1459
 		global $wp_query;
1460 1460
 
1461
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1461
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1462 1462
 
1463
-		return apply_filters( 'give_api_output_format', $format );
1463
+		return apply_filters('give_api_output_format', $format);
1464 1464
 	}
1465 1465
 
1466 1466
 
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 	 *
1477 1477
 	 * @return void
1478 1478
 	 */
1479
-	private function log_request( $data = array() ) {
1480
-		if ( ! $this->log_requests ) {
1479
+	private function log_request($data = array()) {
1480
+		if ( ! $this->log_requests) {
1481 1481
 			return;
1482 1482
 		}
1483 1483
 
@@ -1485,36 +1485,36 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
 		$query = array(
1487 1487
 			'give-api'    => $wp_query->query_vars['give-api'],
1488
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1489
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1490
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1491
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1492
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1493
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1494
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1495
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1496
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1497
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1498
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1499
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1488
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1489
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1490
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1491
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1492
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1493
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1494
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1495
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1496
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1497
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1498
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1499
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1500 1500
 		);
1501 1501
 
1502 1502
 		$log_data = array(
1503 1503
 			'log_type'     => 'api_request',
1504
-			'post_excerpt' => http_build_query( $query ),
1505
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1504
+			'post_excerpt' => http_build_query($query),
1505
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1506 1506
 		);
1507 1507
 
1508 1508
 		$log_meta = array(
1509 1509
 			'request_ip' => give_get_ip(),
1510 1510
 			'user'       => $this->user_id,
1511
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1512
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1511
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1512
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1513 1513
 			'time'       => $data['request_speed'],
1514 1514
 			'version'    => $this->get_queried_version()
1515 1515
 		);
1516 1516
 
1517
-		$give_logs->insert_log( $log_data, $log_meta );
1517
+		$give_logs->insert_log($log_data, $log_meta);
1518 1518
 	}
1519 1519
 
1520 1520
 
@@ -1538,32 +1538,32 @@  discard block
 block discarded – undo
1538 1538
 	 *
1539 1539
 	 * @param int $status_code
1540 1540
 	 */
1541
-	public function output( $status_code = 200 ) {
1541
+	public function output($status_code = 200) {
1542 1542
 		global $wp_query;
1543 1543
 
1544 1544
 		$format = $this->get_output_format();
1545 1545
 
1546
-		status_header( $status_code );
1546
+		status_header($status_code);
1547 1547
 
1548
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1548
+		do_action('give_api_output_before', $this->data, $this, $format);
1549 1549
 
1550
-		switch ( $format ) :
1550
+		switch ($format) :
1551 1551
 
1552 1552
 			case 'xml' :
1553 1553
 
1554
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1555
-				$xml = Array2XML::createXML( 'give', $this->data );
1554
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1555
+				$xml = Array2XML::createXML('give', $this->data);
1556 1556
 				echo $xml->saveXML();
1557 1557
 
1558 1558
 				break;
1559 1559
 
1560 1560
 			case 'json' :
1561 1561
 
1562
-				header( 'Content-Type: application/json' );
1563
-				if ( ! empty( $this->pretty_print ) ) {
1564
-					echo json_encode( $this->data, $this->pretty_print );
1562
+				header('Content-Type: application/json');
1563
+				if ( ! empty($this->pretty_print)) {
1564
+					echo json_encode($this->data, $this->pretty_print);
1565 1565
 				} else {
1566
-					echo json_encode( $this->data );
1566
+					echo json_encode($this->data);
1567 1567
 				}
1568 1568
 
1569 1569
 				break;
@@ -1572,13 +1572,13 @@  discard block
 block discarded – undo
1572 1572
 			default :
1573 1573
 
1574 1574
 				// Allow other formats to be added via extensions
1575
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1575
+				do_action('give_api_output_'.$format, $this->data, $this);
1576 1576
 
1577 1577
 				break;
1578 1578
 
1579 1579
 		endswitch;
1580 1580
 
1581
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1581
+		do_action('give_api_output_after', $this->data, $this, $format);
1582 1582
 
1583 1583
 		give_die();
1584 1584
 	}
@@ -1595,37 +1595,37 @@  discard block
 block discarded – undo
1595 1595
 	 *
1596 1596
 	 * @return void
1597 1597
 	 */
1598
-	function user_key_field( $user ) {
1598
+	function user_key_field($user) {
1599 1599
 
1600
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1601
-			$user = get_userdata( $user->ID );
1600
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1601
+			$user = get_userdata($user->ID);
1602 1602
 			?>
1603 1603
 			<table class="form-table">
1604 1604
 				<tbody>
1605 1605
 				<tr>
1606 1606
 					<th>
1607
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1607
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1608 1608
 					</th>
1609 1609
 					<td>
1610 1610
 						<?php
1611
-						$public_key = $this->get_user_public_key( $user->ID );
1612
-						$secret_key = $this->get_user_secret_key( $user->ID );
1611
+						$public_key = $this->get_user_public_key($user->ID);
1612
+						$secret_key = $this->get_user_secret_key($user->ID);
1613 1613
 						?>
1614
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1614
+						<?php if (empty($user->give_user_public_key)) { ?>
1615 1615
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1616
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1616
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1617 1617
 						<?php } else { ?>
1618
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1619
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php esc_attr_e( $public_key ); ?>"/>
1618
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>&nbsp;</strong>
1619
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php esc_attr_e($public_key); ?>"/>
1620 1620
 							<br/>
1621
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1622
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php esc_attr_e( $secret_key ); ?>"/>
1621
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>&nbsp;</strong>
1622
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php esc_attr_e($secret_key); ?>"/>
1623 1623
 							<br/>
1624
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1625
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php esc_attr_e( $this->get_token( $user->ID ) ); ?>"/>
1624
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>&nbsp;</strong>
1625
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php esc_attr_e($this->get_token($user->ID)); ?>"/>
1626 1626
 							<br/>
1627 1627
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1628
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1628
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1629 1629
 						<?php } ?>
1630 1630
 					</td>
1631 1631
 				</tr>
@@ -1644,69 +1644,69 @@  discard block
 block discarded – undo
1644 1644
 	 *
1645 1645
 	 * @return void
1646 1646
 	 */
1647
-	public function process_api_key( $args ) {
1647
+	public function process_api_key($args) {
1648 1648
 
1649
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1649
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1650 1650
 
1651
-			wp_die( esc_html( 'Nonce verification failed.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
1651
+			wp_die(esc_html('Nonce verification failed.', 'give'), esc_html('Error', 'give'), array('response' => 403));
1652 1652
 
1653 1653
 		}
1654 1654
 
1655
-		if ( empty( $args['user_id'] ) ) {
1656
-			wp_die( esc_html( 'User ID Required.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 401 ) );
1655
+		if (empty($args['user_id'])) {
1656
+			wp_die(esc_html('User ID Required.', 'give'), esc_html('Error', 'give'), array('response' => 401));
1657 1657
 		}
1658 1658
 
1659
-		if ( is_numeric( $args['user_id'] ) ) {
1660
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1659
+		if (is_numeric($args['user_id'])) {
1660
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1661 1661
 		} else {
1662
-			$userdata = get_user_by( 'login', $args['user_id'] );
1662
+			$userdata = get_user_by('login', $args['user_id']);
1663 1663
 			$user_id  = $userdata->ID;
1664 1664
 		}
1665
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1665
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1666 1666
 
1667
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1667
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1668 1668
 			wp_die(
1669 1669
 				sprintf(
1670 1670
 					/* translators: %s: process */
1671
-					esc_html( 'You do not have permission to %s API keys for this user.', 'give' ),
1671
+					esc_html('You do not have permission to %s API keys for this user.', 'give'),
1672 1672
 					$process
1673 1673
 				),
1674
-				esc_html( 'Error', 'give' ),
1675
-				array( 'response' => 403 )
1674
+				esc_html('Error', 'give'),
1675
+				array('response' => 403)
1676 1676
 			);
1677
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1677
+		} elseif ( ! current_user_can('manage_give_settings')) {
1678 1678
 			wp_die(
1679 1679
 				sprintf(
1680 1680
 					/* translators: %s: process */
1681
-					esc_html( 'You do not have permission to %s API keys for this user.', 'give' ),
1681
+					esc_html('You do not have permission to %s API keys for this user.', 'give'),
1682 1682
 					$process
1683 1683
 				),
1684
-				esc_html( 'Error', 'give' ),
1685
-				array( 'response' => 403 )
1684
+				esc_html('Error', 'give'),
1685
+				array('response' => 403)
1686 1686
 			);
1687 1687
 		}
1688 1688
 
1689
-		switch ( $process ) {
1689
+		switch ($process) {
1690 1690
 			case 'generate':
1691
-				if ( $this->generate_api_key( $user_id ) ) {
1692
-					delete_transient( 'give-total-api-keys' );
1693
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1691
+				if ($this->generate_api_key($user_id)) {
1692
+					delete_transient('give-total-api-keys');
1693
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1694 1694
 					exit();
1695 1695
 				} else {
1696
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1696
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1697 1697
 					exit();
1698 1698
 				}
1699 1699
 				break;
1700 1700
 			case 'regenerate':
1701
-				$this->generate_api_key( $user_id, true );
1702
-				delete_transient( 'give-total-api-keys' );
1703
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1701
+				$this->generate_api_key($user_id, true);
1702
+				delete_transient('give-total-api-keys');
1703
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1704 1704
 				exit();
1705 1705
 				break;
1706 1706
 			case 'revoke':
1707
-				$this->revoke_api_key( $user_id );
1708
-				delete_transient( 'give-total-api-keys' );
1709
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1707
+				$this->revoke_api_key($user_id);
1708
+				delete_transient('give-total-api-keys');
1709
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1710 1710
 				exit();
1711 1711
 				break;
1712 1712
 			default;
@@ -1725,34 +1725,34 @@  discard block
 block discarded – undo
1725 1725
 	 *
1726 1726
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1727 1727
 	 */
1728
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1728
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1729 1729
 
1730
-		if ( empty( $user_id ) ) {
1730
+		if (empty($user_id)) {
1731 1731
 			return false;
1732 1732
 		}
1733 1733
 
1734
-		$user = get_userdata( $user_id );
1734
+		$user = get_userdata($user_id);
1735 1735
 
1736
-		if ( ! $user ) {
1736
+		if ( ! $user) {
1737 1737
 			return false;
1738 1738
 		}
1739 1739
 
1740
-		$public_key = $this->get_user_public_key( $user_id );
1741
-		$secret_key = $this->get_user_secret_key( $user_id );
1740
+		$public_key = $this->get_user_public_key($user_id);
1741
+		$secret_key = $this->get_user_secret_key($user_id);
1742 1742
 
1743
-		if ( empty( $public_key ) || $regenerate == true ) {
1744
-			$new_public_key = $this->generate_public_key( $user->user_email );
1745
-			$new_secret_key = $this->generate_private_key( $user->ID );
1743
+		if (empty($public_key) || $regenerate == true) {
1744
+			$new_public_key = $this->generate_public_key($user->user_email);
1745
+			$new_secret_key = $this->generate_private_key($user->ID);
1746 1746
 		} else {
1747 1747
 			return false;
1748 1748
 		}
1749 1749
 
1750
-		if ( $regenerate == true ) {
1751
-			$this->revoke_api_key( $user->ID );
1750
+		if ($regenerate == true) {
1751
+			$this->revoke_api_key($user->ID);
1752 1752
 		}
1753 1753
 
1754
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1755
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1754
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1755
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1756 1756
 
1757 1757
 		return true;
1758 1758
 	}
@@ -1767,26 +1767,26 @@  discard block
 block discarded – undo
1767 1767
 	 *
1768 1768
 	 * @return string
1769 1769
 	 */
1770
-	public function revoke_api_key( $user_id = 0 ) {
1770
+	public function revoke_api_key($user_id = 0) {
1771 1771
 
1772
-		if ( empty( $user_id ) ) {
1772
+		if (empty($user_id)) {
1773 1773
 			return false;
1774 1774
 		}
1775 1775
 
1776
-		$user = get_userdata( $user_id );
1776
+		$user = get_userdata($user_id);
1777 1777
 
1778
-		if ( ! $user ) {
1778
+		if ( ! $user) {
1779 1779
 			return false;
1780 1780
 		}
1781 1781
 
1782
-		$public_key = $this->get_user_public_key( $user_id );
1783
-		$secret_key = $this->get_user_secret_key( $user_id );
1784
-		if ( ! empty( $public_key ) ) {
1785
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1786
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1787
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1788
-			delete_user_meta( $user_id, $public_key );
1789
-			delete_user_meta( $user_id, $secret_key );
1782
+		$public_key = $this->get_user_public_key($user_id);
1783
+		$secret_key = $this->get_user_secret_key($user_id);
1784
+		if ( ! empty($public_key)) {
1785
+			delete_transient(md5('give_api_user_'.$public_key));
1786
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1787
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1788
+			delete_user_meta($user_id, $public_key);
1789
+			delete_user_meta($user_id, $secret_key);
1790 1790
 		} else {
1791 1791
 			return false;
1792 1792
 		}
@@ -1811,22 +1811,22 @@  discard block
 block discarded – undo
1811 1811
 	 *
1812 1812
 	 * @return void
1813 1813
 	 */
1814
-	public function update_key( $user_id ) {
1815
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1814
+	public function update_key($user_id) {
1815
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1816 1816
 
1817
-			$user = get_userdata( $user_id );
1817
+			$user = get_userdata($user_id);
1818 1818
 
1819
-			$public_key = $this->get_user_public_key( $user_id );
1820
-			$secret_key = $this->get_user_secret_key( $user_id );
1819
+			$public_key = $this->get_user_public_key($user_id);
1820
+			$secret_key = $this->get_user_secret_key($user_id);
1821 1821
 
1822
-			if ( empty( $public_key ) ) {
1823
-				$new_public_key = $this->generate_public_key( $user->user_email );
1824
-				$new_secret_key = $this->generate_private_key( $user->ID );
1822
+			if (empty($public_key)) {
1823
+				$new_public_key = $this->generate_public_key($user->user_email);
1824
+				$new_secret_key = $this->generate_private_key($user->ID);
1825 1825
 
1826
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1827
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1826
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1827
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1828 1828
 			} else {
1829
-				$this->revoke_api_key( $user_id );
1829
+				$this->revoke_api_key($user_id);
1830 1830
 			}
1831 1831
 		}
1832 1832
 	}
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 	 *
1842 1842
 	 * @return string
1843 1843
 	 */
1844
-	private function generate_public_key( $user_email = '' ) {
1845
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1846
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1844
+	private function generate_public_key($user_email = '') {
1845
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1846
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1847 1847
 
1848 1848
 		return $public;
1849 1849
 	}
@@ -1858,9 +1858,9 @@  discard block
 block discarded – undo
1858 1858
 	 *
1859 1859
 	 * @return string
1860 1860
 	 */
1861
-	private function generate_private_key( $user_id = 0 ) {
1862
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1863
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1861
+	private function generate_private_key($user_id = 0) {
1862
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1863
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1864 1864
 
1865 1865
 		return $secret;
1866 1866
 	}
@@ -1875,8 +1875,8 @@  discard block
 block discarded – undo
1875 1875
 	 *
1876 1876
 	 * @return string
1877 1877
 	 */
1878
-	public function get_token( $user_id = 0 ) {
1879
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1878
+	public function get_token($user_id = 0) {
1879
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1880 1880
 	}
1881 1881
 
1882 1882
 	/**
@@ -1890,9 +1890,9 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
 		// Default sales return
1892 1892
 		$sales                               = array();
1893
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1894
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1895
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1893
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1894
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1895
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1896 1896
 		$sales['donations']['totals']        = give_get_total_sales();
1897 1897
 
1898 1898
 		return $sales;
@@ -1909,9 +1909,9 @@  discard block
 block discarded – undo
1909 1909
 
1910 1910
 		// Default earnings return
1911 1911
 		$earnings                              = array();
1912
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1913
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1914
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1912
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1913
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1914
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1915 1915
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1916 1916
 
1917 1917
 		return $earnings;
@@ -1931,25 +1931,25 @@  discard block
 block discarded – undo
1931 1931
 	 *
1932 1932
 	 * @return string            The API key/secret for the user supplied
1933 1933
 	 */
1934
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1934
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1935 1935
 
1936
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1936
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1937 1937
 			return $check;
1938 1938
 		}
1939 1939
 
1940 1940
 		$return = $check;
1941 1941
 
1942
-		switch ( $meta_key ) {
1942
+		switch ($meta_key) {
1943 1943
 			case 'give_user_public_key':
1944
-				$return = Give()->api->get_user_public_key( $object_id );
1944
+				$return = Give()->api->get_user_public_key($object_id);
1945 1945
 				break;
1946 1946
 			case 'give_user_secret_key':
1947
-				$return = Give()->api->get_user_secret_key( $object_id );
1947
+				$return = Give()->api->get_user_secret_key($object_id);
1948 1948
 				break;
1949 1949
 		}
1950 1950
 
1951
-		if ( ! $single ) {
1952
-			$return = array( $return );
1951
+		if ( ! $single) {
1952
+			$return = array($return);
1953 1953
 		}
1954 1954
 
1955 1955
 		return $return;
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -50,50 +50,50 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 
52 52
 	// https://gist.github.com/justinph/5197810
53
-	function validate_gravatar( $id_or_email ) {
53
+	function validate_gravatar($id_or_email) {
54 54
 		//id or email code borrowed from wp-includes/pluggable.php
55 55
 		$email = '';
56
-		if ( is_numeric( $id_or_email ) ) {
56
+		if (is_numeric($id_or_email)) {
57 57
 			$id   = (int) $id_or_email;
58
-			$user = get_userdata( $id );
59
-			if ( $user ) {
58
+			$user = get_userdata($id);
59
+			if ($user) {
60 60
 				$email = $user->user_email;
61 61
 			}
62
-		} elseif ( is_object( $id_or_email ) ) {
62
+		} elseif (is_object($id_or_email)) {
63 63
 			// No avatar for pingbacks or trackbacks
64
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
65
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
64
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
65
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
66 66
 				return false;
67 67
 			}
68 68
 
69
-			if ( ! empty( $id_or_email->user_id ) ) {
69
+			if ( ! empty($id_or_email->user_id)) {
70 70
 				$id   = (int) $id_or_email->user_id;
71
-				$user = get_userdata( $id );
72
-				if ( $user ) {
71
+				$user = get_userdata($id);
72
+				if ($user) {
73 73
 					$email = $user->user_email;
74 74
 				}
75
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
75
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
76 76
 				$email = $id_or_email->comment_author_email;
77 77
 			}
78 78
 		} else {
79 79
 			$email = $id_or_email;
80 80
 		}
81 81
 
82
-		$hashkey = md5( strtolower( trim( $email ) ) );
83
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
82
+		$hashkey = md5(strtolower(trim($email)));
83
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
84 84
 
85
-		$data = wp_cache_get( $hashkey );
86
-		if ( false === $data ) {
87
-			$response = wp_remote_head( $uri );
88
-			if ( is_wp_error( $response ) ) {
85
+		$data = wp_cache_get($hashkey);
86
+		if (false === $data) {
87
+			$response = wp_remote_head($uri);
88
+			if (is_wp_error($response)) {
89 89
 				$data = 'not200';
90 90
 			} else {
91 91
 				$data = $response['response']['code'];
92 92
 			}
93
-			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
93
+			wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
94 94
 
95 95
 		}
96
-		if ( $data == '200' ) {
96
+		if ($data == '200') {
97 97
 			return true;
98 98
 		} else {
99 99
 			return false;
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param int $form_id
110 110
 	 */
111
-	function get_log_ids( $form_id = '' ) {
111
+	function get_log_ids($form_id = '') {
112 112
 
113 113
 		// get Give_Logging class
114 114
 		global $give_logs;
115 115
 
116 116
 		// get log for this form
117
-		$logs = $give_logs->get_logs( $form_id );
117
+		$logs = $give_logs->get_logs($form_id);
118 118
 
119
-		if ( $logs ) {
119
+		if ($logs) {
120 120
 			// make an array with all the donor IDs
121
-			foreach ( $logs as $log ) {
121
+			foreach ($logs as $log) {
122 122
 				$log_ids[] = $log->ID;
123 123
 			}
124 124
 
@@ -135,49 +135,49 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @since 1.0
137 137
 	 */
138
-	function get_payment_ids( $form_id = '' ) {
138
+	function get_payment_ids($form_id = '') {
139 139
 
140 140
 		global $give_options;
141 141
 
142
-		$log_ids = $this->get_log_ids( $form_id );
142
+		$log_ids = $this->get_log_ids($form_id);
143 143
 
144
-		if ( $log_ids ) {
144
+		if ($log_ids) {
145 145
 
146 146
 			$payment_ids = array();
147 147
 
148
-			foreach ( $log_ids as $id ) {
148
+			foreach ($log_ids as $id) {
149 149
 				// get the payment ID for each corresponding log ID
150
-				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true );
150
+				$payment_ids[] = get_post_meta($id, '_give_log_payment_id', true);
151 151
 			}
152 152
 
153 153
 			// remove donors who have purchased more than once so we can have unique avatars
154 154
 			$unique_emails = array();
155 155
 
156
-			foreach ( $payment_ids as $key => $id ) {
156
+			foreach ($payment_ids as $key => $id) {
157 157
 
158
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
158
+				$email = get_post_meta($id, '_give_payment_user_email', true);
159 159
 
160
-				if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) {
161
-					if ( ! $this->validate_gravatar( $email ) ) {
160
+				if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) {
161
+					if ( ! $this->validate_gravatar($email)) {
162 162
 						continue;
163 163
 					}
164 164
 				}
165 165
 
166
-				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true );
166
+				$unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true);
167 167
 
168 168
 			}
169 169
 
170 170
 			// strip duplicate emails
171
-			$unique_emails = array_unique( $unique_emails );
171
+			$unique_emails = array_unique($unique_emails);
172 172
 
173 173
 			// convert the unique IDs back into simple array
174
-			foreach ( $unique_emails as $id => $email ) {
174
+			foreach ($unique_emails as $id => $email) {
175 175
 				$unique_ids[] = $id;
176 176
 			}
177 177
 
178 178
 			// randomize the payment IDs if enabled
179
-			if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) {
180
-				shuffle( $unique_ids );
179
+			if (isset($give_options['give_donators_gravatars_random_gravatars'])) {
180
+				shuffle($unique_ids);
181 181
 			}
182 182
 
183 183
 			// return our unique IDs
@@ -193,22 +193,22 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @since 1.0
195 195
 	 */
196
-	function gravatars( $form_id = false, $title = '' ) {
196
+	function gravatars($form_id = false, $title = '') {
197 197
 
198 198
 		// unique $payment_ids 
199
-		$payment_ids = $this->get_payment_ids( $form_id );
199
+		$payment_ids = $this->get_payment_ids($form_id);
200 200
 
201 201
 		global $give_options;
202 202
 
203 203
 		// return if no ID
204
-		if ( ! $form_id ) {
204
+		if ( ! $form_id) {
205 205
 			return;
206 206
 		}
207 207
 
208 208
 		// minimum amount of purchases before showing gravatars
209 209
 		// if the number of items in array is not greater or equal to the number specified, then exit
210
-		if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) {
211
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) {
210
+		if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) {
211
+			if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) {
212 212
 				return;
213 213
 			}
214 214
 		}
@@ -219,51 +219,51 @@  discard block
 block discarded – undo
219 219
 		echo '<div id="give-purchase-gravatars">';
220 220
 
221 221
 
222
-		if ( isset ( $title ) ) {
222
+		if (isset ($title)) {
223 223
 
224
-			if ( $title ) {
225
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_html( $title ) . '</h3>' );
226
-			} elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) {
227
-				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_html( $give_options['give_donators_gravatars_heading'] ) . '</h2>' );
224
+			if ($title) {
225
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_html($title).'</h3>');
226
+			} elseif (isset($give_options['give_donators_gravatars_heading'])) {
227
+				echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_html($give_options['give_donators_gravatars_heading']).'</h2>');
228 228
 			}
229 229
 
230 230
 		}
231 231
 		echo '<ul class="give-purchase-gravatars-list">';
232 232
 		$i = 0;
233 233
 
234
-		if ( $payment_ids ) {
235
-			foreach ( $payment_ids as $id ) {
234
+		if ($payment_ids) {
235
+			foreach ($payment_ids as $id) {
236 236
 
237 237
 				// Give saves a blank option even when the control is turned off, hence the extra check
238
-				if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) {
238
+				if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) {
239 239
 					continue;
240 240
 				}
241 241
 
242 242
 				// get the payment meta
243
-				$payment_meta = get_post_meta( $id, '_give_payment_meta', true );
243
+				$payment_meta = get_post_meta($id, '_give_payment_meta', true);
244 244
 
245 245
 				// unserialize the payment meta
246
-				$user_info = maybe_unserialize( $payment_meta['user_info'] );
246
+				$user_info = maybe_unserialize($payment_meta['user_info']);
247 247
 
248 248
 				// get donor's first name
249 249
 				$name = $user_info['first_name'];
250 250
 
251 251
 				// get donor's email
252
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
252
+				$email = get_post_meta($id, '_give_payment_user_email', true);
253 253
 
254 254
 				// set gravatar size and provide filter
255
-				$size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : '';
255
+				$size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : '';
256 256
 
257 257
 				// default image
258
-				$default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false );
258
+				$default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false);
259 259
 
260 260
 				// assemble output
261 261
 				$output .= '<li>';
262 262
 
263
-				$output .= get_avatar( $email, $size, $default_image, $name );
263
+				$output .= get_avatar($email, $size, $default_image, $name);
264 264
 				$output .= '</li>';
265 265
 
266
-				$i ++;
266
+				$i++;
267 267
 
268 268
 			} // end foreach
269 269
 		}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		echo '</ul>';
273 273
 		echo '</div>';
274 274
 
275
-		return apply_filters( 'give_donators_gravatars', ob_get_clean() );
275
+		return apply_filters('give_donators_gravatars', ob_get_clean());
276 276
 	}
277 277
 
278 278
 	/**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 * @since 1.0
282 282
 	 */
283 283
 	function register_widget() {
284
-		register_widget( 'Give_Donators_Gravatars_Widget' );
284
+		register_widget('Give_Donators_Gravatars_Widget');
285 285
 	}
286 286
 
287 287
 	/**
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 	 * @since 1.0
291 291
 	 * @todo  set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars
292 292
 	 */
293
-	function shortcode( $atts, $content = null ) {
293
+	function shortcode($atts, $content = null) {
294 294
 
295
-		$atts = shortcode_atts( array(
295
+		$atts = shortcode_atts(array(
296 296
 			'id'    => '',
297 297
 			'title' => ''
298
-		), $atts, 'give_donators_gravatars' );
298
+		), $atts, 'give_donators_gravatars');
299 299
 
300 300
 		// if no ID is passed on single give_forms pages, get the correct ID
301
-		if ( is_singular( 'give_forms' ) ) {
301
+		if (is_singular('give_forms')) {
302 302
 			$id = get_the_ID();
303 303
 		}
304 304
 
305
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
305
+		$content = $this->gravatars($atts['id'], $atts['title']);
306 306
 
307 307
 		return $content;
308 308
 
@@ -313,57 +313,57 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @since 1.0
315 315
 	 */
316
-	function settings( $settings ) {
316
+	function settings($settings) {
317 317
 
318 318
 		$give_gravatar_settings = array(
319 319
 			array(
320
-				'name' => esc_html( 'Donator Gravatars', 'give' ),
320
+				'name' => esc_html('Donator Gravatars', 'give'),
321 321
 				'desc' => '<hr>',
322 322
 				'id'   => 'give_title',
323 323
 				'type' => 'give_title'
324 324
 			),
325 325
 			array(
326
-				'name' => esc_html( 'Heading', 'give' ),
327
-				'desc' => esc_html( 'The heading to display above the Gravatars', 'give' ),
326
+				'name' => esc_html('Heading', 'give'),
327
+				'desc' => esc_html('The heading to display above the Gravatars', 'give'),
328 328
 				'type' => 'text',
329 329
 				'id'   => 'give_donators_gravatars_heading'
330 330
 			),
331 331
 			array(
332
-				'name'    => esc_html( 'Gravatar Size', 'give' ),
333
-				'desc'    => esc_html( 'The size of each Gravatar in pixels (512px maximum)', 'give' ),
332
+				'name'    => esc_html('Gravatar Size', 'give'),
333
+				'desc'    => esc_html('The size of each Gravatar in pixels (512px maximum)', 'give'),
334 334
 				'type'    => 'text_small',
335 335
 				'id'      => 'give_donators_gravatars_gravatar_size',
336 336
 				'default' => '64'
337 337
 			),
338 338
 			array(
339
-				'name' => esc_html( 'Minimum Unique Purchases Required', 'give' ),
339
+				'name' => esc_html('Minimum Unique Purchases Required', 'give'),
340 340
 				/* translators: %s: form singular label */
341
-				'desc' => sprintf( esc_html( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ),
341
+				'desc' => sprintf(esc_html('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())),
342 342
 				'type' => 'text_small',
343 343
 				'id'   => 'give_donators_gravatars_min_purchases_required',
344 344
 			),
345 345
 			array(
346
-				'name'    => esc_html( 'Maximum Gravatars To Show', 'give' ),
347
-				'desc'    => esc_html( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
346
+				'name'    => esc_html('Maximum Gravatars To Show', 'give'),
347
+				'desc'    => esc_html('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
348 348
 				'type'    => 'text',
349 349
 				'id'      => 'give_donators_gravatars_maximum_number',
350 350
 				'default' => '20',
351 351
 			),
352 352
 			array(
353
-				'name' => esc_html( 'Gravatar Visibility', 'give' ),
354
-				'desc' => esc_html( 'Only show donators with a Gravatar account', 'give' ),
353
+				'name' => esc_html('Gravatar Visibility', 'give'),
354
+				'desc' => esc_html('Only show donators with a Gravatar account', 'give'),
355 355
 				'id'   => 'give_donators_gravatars_has_gravatar_account',
356 356
 				'type' => 'checkbox',
357 357
 			),
358 358
 			array(
359
-				'name' => esc_html( 'Randomize Gravatars', 'give' ),
360
-				'desc' => esc_html( 'Randomize the Gravatars', 'give' ),
359
+				'name' => esc_html('Randomize Gravatars', 'give'),
360
+				'desc' => esc_html('Randomize the Gravatars', 'give'),
361 361
 				'id'   => 'give_donators_gravatars_random_gravatars',
362 362
 				'type' => 'checkbox',
363 363
 			),
364 364
 		);
365 365
 
366
-		return array_merge( $settings, $give_gravatar_settings );
366
+		return array_merge($settings, $give_gravatar_settings);
367 367
 	}
368 368
 
369 369
 }
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function __construct() {
383 383
 
384
-		$give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null;
384
+		$give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null;
385 385
 
386 386
 		// widget settings
387 387
 		$widget_ops = array(
388 388
 			'classname'   => 'give-donators-gravatars',
389 389
 			/* translators: 1: form singular label 2: form singular label */
390
-			'description' => sprintf( esc_html( 'Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give' ), $give_label_singular, $give_label_singular )
390
+			'description' => sprintf(esc_html('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular)
391 391
 		);
392 392
 
393 393
 		// widget control settings
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		// create the widget
401 401
 		parent::__construct(
402 402
 			'give_donators_gravatars_widget',
403
-			esc_html( 'Give Donators Gravatars', 'give' ),
403
+			esc_html('Give Donators Gravatars', 'give'),
404 404
 			$widget_ops,
405 405
 			$control_ops
406 406
 		);
@@ -411,30 +411,30 @@  discard block
 block discarded – undo
411 411
 	/*
412 412
 	 * Outputs the content of the widget
413 413
 	 */
414
-	function widget( $args, $instance ) {
414
+	function widget($args, $instance) {
415 415
 		global $give_options;
416 416
 
417 417
 		//@TODO: Don't extract it!!!
418
-		extract( $args );
418
+		extract($args);
419 419
 
420
-		if ( ! is_singular( 'give_forms' ) ) {
420
+		if ( ! is_singular('give_forms')) {
421 421
 			return;
422 422
 		}
423 423
 
424 424
 		// Variables from widget settings
425
-		$title = apply_filters( 'widget_title', $instance['title'] );
425
+		$title = apply_filters('widget_title', $instance['title']);
426 426
 
427 427
 		// Used by themes. Opens the widget
428 428
 		echo $before_widget;
429 429
 
430 430
 		// Display the widget title
431
-		if ( $title ) {
432
-			echo $before_title . $title . $after_title;
431
+		if ($title) {
432
+			echo $before_title.$title.$after_title;
433 433
 		}
434 434
 
435 435
 		$gravatars = new Give_Donators_Gravatars();
436 436
 
437
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
437
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
438 438
 
439 439
 		// Used by themes. Closes the widget
440 440
 		echo $after_widget;
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	/*
445 445
 	 * Update function. Processes widget options to be saved
446 446
 	 */
447
-	function update( $new_instance, $old_instance ) {
447
+	function update($new_instance, $old_instance) {
448 448
 
449 449
 		$instance = $old_instance;
450 450
 
451
-		$instance['title'] = strip_tags( $new_instance['title'] );
451
+		$instance['title'] = strip_tags($new_instance['title']);
452 452
 
453 453
 		return $instance;
454 454
 
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 	/*
458 458
 	 * Form function. Displays the actual form on the widget page
459 459
 	 */
460
-	function form( $instance ) {
460
+	function form($instance) {
461 461
 
462 462
 		// Set up some default widget settings.
463 463
 		$defaults = array(
464 464
 			'title' => '',
465 465
 		);
466 466
 
467
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
467
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
468 468
 
469 469
 		<!-- Title -->
470 470
 		<p>
471
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label>
472
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
471
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label>
472
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
473 473
 		</p>
474 474
 
475 475
 
Please login to merge, or discard this patch.
includes/admin/payments/view-order-details.php 1 patch
Spacing   +127 added lines, -127 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
 
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
  * @since 1.0
21 21
  * @return void
22 22
  */
23
-if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
24
-	wp_die( esc_html( 'Donation ID not supplied. Please try again', 'give' ), esc_html( 'Error', 'give' ) );
23
+if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
24
+	wp_die(esc_html('Donation ID not supplied. Please try again', 'give'), esc_html('Error', 'give'));
25 25
 }
26 26
 
27 27
 // Setup the variables
28
-$payment_id = absint( $_GET['id'] );
29
-$payment    = new Give_Payment( $payment_id );
28
+$payment_id = absint($_GET['id']);
29
+$payment    = new Give_Payment($payment_id);
30 30
 
31 31
 // Sanity check... fail if purchase ID is invalid
32 32
 $payment_exists = $payment->ID;
33
-if ( empty( $payment_exists ) ) {
34
-	wp_die( esc_html( 'The specified ID does not belong to a payment. Please try again', 'give' ), esc_html( 'Error', 'give' ) );
33
+if (empty($payment_exists)) {
34
+	wp_die(esc_html('The specified ID does not belong to a payment. Please try again', 'give'), esc_html('Error', 'give'));
35 35
 }
36 36
 
37 37
 $number         = $payment->number;
38 38
 $payment_meta   = $payment->get_meta();
39
-$transaction_id = esc_attr( $payment->transaction_id );
39
+$transaction_id = esc_attr($payment->transaction_id);
40 40
 $user_id        = $payment->user_id;
41 41
 $customer_id    = $payment->customer_id;
42
-$payment_date   = strtotime( $payment->date );
43
-$user_info      = give_get_payment_meta_user_info( $payment_id );
42
+$payment_date   = strtotime($payment->date);
43
+$user_info      = give_get_payment_meta_user_info($payment_id);
44 44
 $address        = $payment->address;
45 45
 $gateway        = $payment->gateway;
46 46
 $currency_code  = $payment->currency;
@@ -52,76 +52,76 @@  discard block
 block discarded – undo
52 52
 	<h1 id="transaction-details-heading"><?php
53 53
 		printf(
54 54
 			/* translators: %s: payment number */
55
-			esc_html( 'Payment %s', 'give' ),
55
+			esc_html('Payment %s', 'give'),
56 56
 			$number
57 57
 		);
58
-		if ( $payment_mode == 'test' ) {
59
-			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="' . esc_attr( 'This payment was made in Test Mode', 'give' ) . '" data-tooltip-my-position="center left" data-tooltip-target-position="center right">' . esc_html( 'Test Payment', 'give' ) . '</span>';
58
+		if ($payment_mode == 'test') {
59
+			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="'.esc_attr('This payment was made in Test Mode', 'give').'" data-tooltip-my-position="center left" data-tooltip-target-position="center right">'.esc_html('Test Payment', 'give').'</span>';
60 60
 		}
61 61
 	?></h1>
62 62
 
63
-	<?php do_action( 'give_view_order_details_before', $payment_id ); ?>
63
+	<?php do_action('give_view_order_details_before', $payment_id); ?>
64 64
 	<form id="give-edit-order-form" method="post">
65
-		<?php do_action( 'give_view_order_details_form_top', $payment_id ); ?>
65
+		<?php do_action('give_view_order_details_form_top', $payment_id); ?>
66 66
 		<div id="poststuff">
67 67
 			<div id="give-dashboard-widgets-wrap">
68 68
 				<div id="post-body" class="metabox-holder columns-2">
69 69
 					<div id="postbox-container-1" class="postbox-container">
70 70
 						<div id="side-sortables" class="meta-box-sortables ui-sortable">
71 71
 
72
-							<?php do_action( 'give_view_order_details_sidebar_before', $payment_id ); ?>
72
+							<?php do_action('give_view_order_details_sidebar_before', $payment_id); ?>
73 73
 
74 74
 
75 75
 							<div id="give-order-update" class="postbox give-order-data">
76 76
 
77 77
 								<h3 class="hndle">
78
-									<span><?php esc_html_e( 'Update Payment', 'give' ); ?></span>
78
+									<span><?php esc_html_e('Update Payment', 'give'); ?></span>
79 79
 								</h3>
80 80
 
81 81
 								<div class="inside">
82 82
 									<div class="give-admin-box">
83 83
 
84
-										<?php do_action( 'give_view_order_details_totals_before', $payment_id ); ?>
84
+										<?php do_action('give_view_order_details_totals_before', $payment_id); ?>
85 85
 
86 86
 										<div class="give-admin-box-inside">
87 87
 											<p>
88
-												<span class="label"><?php esc_html_e( 'Status:', 'give' ); ?></span>&nbsp;
88
+												<span class="label"><?php esc_html_e('Status:', 'give'); ?></span>&nbsp;
89 89
 												<select name="give-payment-status" class="medium-text">
90
-													<?php foreach ( give_get_payment_statuses() as $key => $status ) : ?>
91
-														<option value="<?php esc_attr_e( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php esc_html_e( $status ); ?></option>
90
+													<?php foreach (give_get_payment_statuses() as $key => $status) : ?>
91
+														<option value="<?php esc_attr_e($key); ?>"<?php selected($payment->status, $key, true); ?>><?php esc_html_e($status); ?></option>
92 92
 													<?php endforeach; ?>
93 93
 												</select>
94
-												<span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span>
94
+												<span class="give-donation-status status-<?php echo sanitize_title($payment->status); ?>"><span class="give-donation-status-icon"></span></span>
95 95
 											</p>
96 96
 										</div>
97 97
 
98 98
 										<div class="give-admin-box-inside">
99 99
 											<p>
100
-												<span class="label"><?php esc_html_e( 'Date:', 'give' ); ?></span>&nbsp;
101
-												<input type="text" name="give-payment-date" value="<?php esc_attr_e( date( 'm/d/Y', $payment_date ) ); ?>" class="medium-text give_datepicker"/>
100
+												<span class="label"><?php esc_html_e('Date:', 'give'); ?></span>&nbsp;
101
+												<input type="text" name="give-payment-date" value="<?php esc_attr_e(date('m/d/Y', $payment_date)); ?>" class="medium-text give_datepicker"/>
102 102
 											</p>
103 103
 										</div>
104 104
 
105 105
 										<div class="give-admin-box-inside">
106 106
 											<p>
107
-												<span class="label"><?php esc_html_e( 'Time:', 'give' ); ?></span>&nbsp;
108
-												<input type="number" step="1" max="24" name="give-payment-time-hour" value="<?php esc_attr_e( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
109
-												<input type="number" step="1" max="59" name="give-payment-time-min" value="<?php esc_attr_e( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/>
107
+												<span class="label"><?php esc_html_e('Time:', 'give'); ?></span>&nbsp;
108
+												<input type="number" step="1" max="24" name="give-payment-time-hour" value="<?php esc_attr_e(date_i18n('H', $payment_date)); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
109
+												<input type="number" step="1" max="59" name="give-payment-time-min" value="<?php esc_attr_e(date('i', $payment_date)); ?>" class="small-text give-payment-time-min"/>
110 110
 											</p>
111 111
 										</div>
112 112
 
113
-										<?php do_action( 'give_view_order_details_update_inner', $payment_id ); ?>
113
+										<?php do_action('give_view_order_details_update_inner', $payment_id); ?>
114 114
 
115 115
 										<?php
116 116
 										//@TODO: Fees
117
-										$fees = give_get_payment_fees( $payment_id );
118
-										if ( ! empty( $fees ) ) : ?>
117
+										$fees = give_get_payment_fees($payment_id);
118
+										if ( ! empty($fees)) : ?>
119 119
 											<div class="give-order-fees give-admin-box-inside">
120
-												<p class="strong"><?php esc_html_e( 'Fees', 'give' ); ?>:</p>
120
+												<p class="strong"><?php esc_html_e('Fees', 'give'); ?>:</p>
121 121
 												<ul class="give-payment-fees">
122
-													<?php foreach ( $fees as $fee ) : ?>
122
+													<?php foreach ($fees as $fee) : ?>
123 123
 														<li>
124
-															<span class="fee-label"><?php echo $fee['label'] . ':</span> ' . '<span class="fee-amount" data-fee="' . esc_attr( $fee['amount'] ) . '">' . give_currency_filter( $fee['amount'], $currency_code ); ?></span>
124
+															<span class="fee-label"><?php echo $fee['label'].':</span> '.'<span class="fee-amount" data-fee="'.esc_attr($fee['amount']).'">'.give_currency_filter($fee['amount'], $currency_code); ?></span>
125 125
 														</li>
126 126
 													<?php endforeach; ?>
127 127
 												</ul>
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 
132 132
 										<div class="give-order-payment give-admin-box-inside">
133 133
 											<p>
134
-												<span class="label"><?php esc_html_e( 'Total Donation', 'give' ); ?>:</span>&nbsp;
135
-												<?php echo give_currency_symbol( $payment->currency ); ?>&nbsp;<input name="give-payment-total" type="text" class="small-text give-price-field" value="<?php esc_attr_e( give_format_amount( give_get_payment_amount( $payment_id ) ) ); ?>"/>
134
+												<span class="label"><?php esc_html_e('Total Donation', 'give'); ?>:</span>&nbsp;
135
+												<?php echo give_currency_symbol($payment->currency); ?>&nbsp;<input name="give-payment-total" type="text" class="small-text give-price-field" value="<?php esc_attr_e(give_format_amount(give_get_payment_amount($payment_id))); ?>"/>
136 136
 											</p>
137 137
 										</div>
138 138
 
139
-										<?php do_action( 'give_view_order_details_totals_after', $payment_id ); ?>
139
+										<?php do_action('give_view_order_details_totals_after', $payment_id); ?>
140 140
 
141 141
 									</div>
142 142
 									<!-- /.give-admin-box -->
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
 								<!-- /.inside -->
146 146
 
147 147
 								<div class="give-order-update-box give-admin-box">
148
-									<?php do_action( 'give_view_order_details_update_before', $payment_id ); ?>
148
+									<?php do_action('give_view_order_details_update_before', $payment_id); ?>
149 149
 									<div id="major-publishing-actions">
150 150
 										<div id="publishing-action">
151
-											<input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Payment', 'give' ); ?>"/>
152
-											<?php if ( give_is_payment_complete( $payment_id ) ) : ?>
153
-												<a href="<?php echo esc_url( add_query_arg( array(
151
+											<input type="submit" class="button button-primary right" value="<?php esc_attr_e('Save Payment', 'give'); ?>"/>
152
+											<?php if (give_is_payment_complete($payment_id)) : ?>
153
+												<a href="<?php echo esc_url(add_query_arg(array(
154 154
 													'give-action' => 'email_links',
155 155
 													'purchase_id' => $payment_id
156
-												) ) ); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e( 'Resend Receipt', 'give' ); ?></a>
156
+												))); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e('Resend Receipt', 'give'); ?></a>
157 157
 											<?php endif; ?>
158 158
 										</div>
159 159
 										<div class="clear"></div>
160 160
 									</div>
161
-									<?php do_action( 'give_view_order_details_update_after', $payment_id ); ?>
161
+									<?php do_action('give_view_order_details_update_after', $payment_id); ?>
162 162
 								</div>
163 163
 								<!-- /.give-order-update-box -->
164 164
 
@@ -168,55 +168,55 @@  discard block
 block discarded – undo
168 168
 							<div id="give-order-details" class="postbox give-order-data">
169 169
 
170 170
 								<h3 class="hndle">
171
-									<span><?php esc_html_e( 'Payment Meta', 'give' ); ?></span>
171
+									<span><?php esc_html_e('Payment Meta', 'give'); ?></span>
172 172
 								</h3>
173 173
 
174 174
 								<div class="inside">
175 175
 									<div class="give-admin-box">
176 176
 
177
-										<?php do_action( 'give_view_order_details_payment_meta_before', $payment_id ); ?>
177
+										<?php do_action('give_view_order_details_payment_meta_before', $payment_id); ?>
178 178
 
179 179
 										<?php
180
-										$gateway = give_get_payment_gateway( $payment_id );
181
-										if ( $gateway ) : ?>
180
+										$gateway = give_get_payment_gateway($payment_id);
181
+										if ($gateway) : ?>
182 182
 											<div class="give-order-gateway give-admin-box-inside">
183 183
 												<p>
184
-													<span class="label"><?php esc_html_e( 'Gateway:', 'give' ); ?></span>&nbsp;
185
-													<?php echo give_get_gateway_admin_label( $gateway ); ?>
184
+													<span class="label"><?php esc_html_e('Gateway:', 'give'); ?></span>&nbsp;
185
+													<?php echo give_get_gateway_admin_label($gateway); ?>
186 186
 												</p>
187 187
 											</div>
188 188
 										<?php endif; ?>
189 189
 
190 190
 										<div class="give-order-payment-key give-admin-box-inside">
191 191
 											<p>
192
-												<span class="label"><?php esc_html_e( 'Key:', 'give' ); ?></span>&nbsp;
193
-												<span><?php echo give_get_payment_key( $payment_id ); ?></span>
192
+												<span class="label"><?php esc_html_e('Key:', 'give'); ?></span>&nbsp;
193
+												<span><?php echo give_get_payment_key($payment_id); ?></span>
194 194
 											</p>
195 195
 										</div>
196 196
 
197 197
 										<div class="give-order-ip give-admin-box-inside">
198 198
 											<p>
199
-												<span class="label"><?php esc_html_e( 'IP:', 'give' ); ?></span>&nbsp;
200
-												<span><?php esc_html_e( give_get_payment_user_ip( $payment_id ) ); ?></span>
199
+												<span class="label"><?php esc_html_e('IP:', 'give'); ?></span>&nbsp;
200
+												<span><?php esc_html_e(give_get_payment_user_ip($payment_id)); ?></span>
201 201
 											</p>
202 202
 										</div>
203 203
 
204
-										<?php if ( $transaction_id ) : ?>
204
+										<?php if ($transaction_id) : ?>
205 205
 											<div class="give-order-tx-id give-admin-box-inside">
206 206
 												<p>
207
-													<span class="label"><?php esc_html_e( 'Transaction ID:', 'give' ); ?></span>&nbsp;
208
-													<span><?php echo apply_filters( 'give_payment_details_transaction_id-' . $gateway, $transaction_id, $payment_id ); ?></span>
207
+													<span class="label"><?php esc_html_e('Transaction ID:', 'give'); ?></span>&nbsp;
208
+													<span><?php echo apply_filters('give_payment_details_transaction_id-'.$gateway, $transaction_id, $payment_id); ?></span>
209 209
 												</p>
210 210
 											</div>
211 211
 										<?php endif; ?>
212 212
 
213 213
 										<div class="give-admin-box-inside">
214
-											<p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . esc_attr( give_get_payment_user_email( $payment_id ) ) ); ?>
215
-												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e( 'View all donations for this donor', 'give' ); ?> &raquo;</a>
214
+											<p><?php $purchase_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.esc_attr(give_get_payment_user_email($payment_id))); ?>
215
+												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e('View all donations for this donor', 'give'); ?> &raquo;</a>
216 216
 											</p>
217 217
 										</div>
218 218
 
219
-										<?php do_action( 'give_view_order_details_payment_meta_after', $payment_id ); ?>
219
+										<?php do_action('give_view_order_details_payment_meta_after', $payment_id); ?>
220 220
 
221 221
 									</div>
222 222
 									<!-- /.column-container -->
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 							</div>
228 228
 							<!-- /#give-order-data -->
229 229
 
230
-							<?php do_action( 'give_view_order_details_sidebar_after', $payment_id ); ?>
230
+							<?php do_action('give_view_order_details_sidebar_after', $payment_id); ?>
231 231
 
232 232
 						</div>
233 233
 						<!-- /#side-sortables -->
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 
239 239
 						<div id="normal-sortables" class="meta-box-sortables ui-sortable">
240 240
 
241
-							<?php do_action( 'give_view_order_details_main_before', $payment_id ); ?>
241
+							<?php do_action('give_view_order_details_main_before', $payment_id); ?>
242 242
 
243 243
 							<?php $column_count = 'columns-3'; ?>
244 244
 							<div id="give-donation-overview" class="postbox <?php echo $column_count; ?>">
245 245
 								<h3 class="hndle">
246
-									<span><?php esc_html_e( 'Donation Information', 'give' ); ?></span>
246
+									<span><?php esc_html_e('Donation Information', 'give'); ?></span>
247 247
 								</h3>
248 248
 
249 249
 								<div class="inside">
@@ -251,29 +251,29 @@  discard block
 block discarded – undo
251 251
 									<table style="width:100%;text-align:left;">
252 252
 										<thead>
253 253
 										<tr>
254
-											<?php do_action( 'give_donation_details_thead_before', $payment_id ); ?>
255
-											<th><?php esc_html_e( 'Donation Form ID', 'give' ) ?></th>
256
-											<th><?php esc_html_e( 'Donation Form Title', 'give' ) ?></th>
257
-											<th><?php esc_html_e( 'Donation Level', 'give' ) ?></th>
258
-											<th><?php esc_html_e( 'Donation Date', 'give' ) ?></th>
259
-											<th><?php esc_html_e( 'Total Donation', 'give' ) ?></th>
260
-											<?php do_action( 'give_donation_details_thead_after', $payment_id ); ?>
254
+											<?php do_action('give_donation_details_thead_before', $payment_id); ?>
255
+											<th><?php esc_html_e('Donation Form ID', 'give') ?></th>
256
+											<th><?php esc_html_e('Donation Form Title', 'give') ?></th>
257
+											<th><?php esc_html_e('Donation Level', 'give') ?></th>
258
+											<th><?php esc_html_e('Donation Date', 'give') ?></th>
259
+											<th><?php esc_html_e('Total Donation', 'give') ?></th>
260
+											<?php do_action('give_donation_details_thead_after', $payment_id); ?>
261 261
 										</tr>
262 262
 										</thead>
263 263
 										<tr>
264
-											<?php do_action( 'give_donation_details_tbody_before', $payment_id ); ?>
264
+											<?php do_action('give_donation_details_tbody_before', $payment_id); ?>
265 265
 											<td>
266 266
 												<?php echo $payment_meta['form_id']; ?>
267 267
 											</td>
268 268
 											<td>
269
-												<a href="<?php echo get_permalink( $payment_meta['form_id'] ); ?>"><?php echo $payment_meta['form_title']; ?></a>
269
+												<a href="<?php echo get_permalink($payment_meta['form_id']); ?>"><?php echo $payment_meta['form_title']; ?></a>
270 270
 											</td>
271 271
 											<td>
272 272
 												<?php
273 273
 												//Level ID
274
-												$level_title = give_get_payment_form_title( $payment_meta, true );
275
-												if ( empty( $level_title ) ) {
276
-													esc_html_e( 'n/a', 'give' );
274
+												$level_title = give_get_payment_form_title($payment_meta, true);
275
+												if (empty($level_title)) {
276
+													esc_html_e('n/a', 'give');
277 277
 												} else {
278 278
 													echo $level_title;
279 279
 												} ?>
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 											<td>
282 282
 												<?php
283 283
 												//Transaction Date
284
-												$date_format = get_option( 'date_format' );
285
-												echo date_i18n( $date_format, strtotime( $payment_date ) );
284
+												$date_format = get_option('date_format');
285
+												echo date_i18n($date_format, strtotime($payment_date));
286 286
 												?>
287 287
 											</td>
288 288
 											<td>
289
-												<?php esc_html_e( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ) ); ?></td>
290
-											<?php do_action( 'give_donation_details_tbody_after', $payment_id ); ?>
289
+												<?php esc_html_e(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)))); ?></td>
290
+											<?php do_action('give_donation_details_tbody_after', $payment_id); ?>
291 291
 
292 292
 										</tr>
293 293
 									</table>
@@ -299,64 +299,64 @@  discard block
 block discarded – undo
299 299
 							</div>
300 300
 							<!-- /#give-donation-overview -->
301 301
 
302
-							<?php do_action( 'give_view_order_details_files_after', $payment_id ); ?>
302
+							<?php do_action('give_view_order_details_files_after', $payment_id); ?>
303 303
 
304
-							<?php do_action( 'give_view_order_details_billing_before', $payment_id ); ?>
304
+							<?php do_action('give_view_order_details_billing_before', $payment_id); ?>
305 305
 
306 306
 
307 307
 							<div id="give-customer-details" class="postbox">
308 308
 								<h3 class="hndle">
309
-									<span><?php esc_html_e( 'Donor Details', 'give' ); ?></span>
309
+									<span><?php esc_html_e('Donor Details', 'give'); ?></span>
310 310
 								</h3>
311 311
 
312 312
 								<div class="inside give-clearfix">
313 313
 
314
-									<?php $customer = new Give_Customer( $customer_id ); ?>
314
+									<?php $customer = new Give_Customer($customer_id); ?>
315 315
 
316 316
 									<div class="column-container customer-info">
317 317
 										<div class="column">
318
-											<?php echo Give()->html->donor_dropdown( array(
318
+											<?php echo Give()->html->donor_dropdown(array(
319 319
 												'selected' => $customer->id,
320 320
 												'name'     => 'customer-id'
321
-											) ); ?>
321
+											)); ?>
322 322
 										</div>
323 323
 										<div class="column">
324 324
 											<input type="hidden" name="give-current-customer" value="<?php echo $customer->id; ?>"/>
325 325
 										</div>
326 326
 										<div class="column">
327
-											<?php if ( ! empty( $customer->id ) ) : ?>
328
-												<?php $customer_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>
329
-												<a href="<?php echo $customer_url; ?>" title="<?php esc_attr_e( 'View Donor Details', 'give' ); ?>"><?php esc_html_e( 'View Donor Details', 'give' ); ?></a>
327
+											<?php if ( ! empty($customer->id)) : ?>
328
+												<?php $customer_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>
329
+												<a href="<?php echo $customer_url; ?>" title="<?php esc_attr_e('View Donor Details', 'give'); ?>"><?php esc_html_e('View Donor Details', 'give'); ?></a>
330 330
 												&nbsp;|&nbsp;
331 331
 											<?php endif; ?>
332
-											<a href="#new" class="give-payment-new-customer" title="<?php esc_attr_e( 'New Donor', 'give' ); ?>"><?php esc_html_e( 'New Donor', 'give' ); ?></a>
332
+											<a href="#new" class="give-payment-new-customer" title="<?php esc_attr_e('New Donor', 'give'); ?>"><?php esc_html_e('New Donor', 'give'); ?></a>
333 333
 										</div>
334 334
 									</div>
335 335
 
336 336
 									<div class="column-container new-customer" style="display: none">
337 337
 										<div class="column">
338
-											<strong><?php esc_html_e( 'Name:', 'give' ); ?></strong>&nbsp;
338
+											<strong><?php esc_html_e('Name:', 'give'); ?></strong>&nbsp;
339 339
 											<input type="text" name="give-new-customer-name" value="" class="medium-text"/>
340 340
 										</div>
341 341
 										<div class="column">
342
-											<strong><?php esc_html_e( 'Email:', 'give' ); ?></strong>&nbsp;
342
+											<strong><?php esc_html_e('Email:', 'give'); ?></strong>&nbsp;
343 343
 											<input type="email" name="give-new-customer-email" value="" class="medium-text"/>
344 344
 										</div>
345 345
 										<div class="column">
346 346
 											<input type="hidden" id="give-new-customer" name="give-new-customer" value="0"/>
347
-											<a href="#cancel" class="give-payment-new-customer-cancel give-delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
347
+											<a href="#cancel" class="give-payment-new-customer-cancel give-delete"><?php esc_html_e('Cancel', 'give'); ?></a>
348 348
 										</div>
349 349
 										<div class="column">
350 350
 											<small>
351
-												<em>*<?php esc_html_e( 'Click "Save Payment" to create new donor', 'give' ); ?></em>
351
+												<em>*<?php esc_html_e('Click "Save Payment" to create new donor', 'give'); ?></em>
352 352
 											</small>
353 353
 										</div>
354 354
 									</div>
355 355
 
356 356
 									<?php
357 357
 									// The give_payment_personal_details_list hook is left here for backwards compatibility
358
-									do_action( 'give_payment_personal_details_list', $payment_meta, $user_info );
359
-									do_action( 'give_payment_view_details', $payment_id );
358
+									do_action('give_payment_personal_details_list', $payment_meta, $user_info);
359
+									do_action('give_payment_view_details', $payment_id);
360 360
 									?>
361 361
 
362 362
 								</div>
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 							<div id="give-billing-details" class="postbox">
369 369
 								<h3 class="hndle">
370
-									<span><?php esc_html_e( 'Billing Address', 'give' ); ?></span>
370
+									<span><?php esc_html_e('Billing Address', 'give'); ?></span>
371 371
 								</h3>
372 372
 
373 373
 								<div class="inside give-clearfix">
@@ -378,62 +378,62 @@  discard block
 block discarded – undo
378 378
 											<div class="data column-container">
379 379
 												<div class="column">
380 380
 													<p>
381
-														<strong class="order-data-address-line"><?php esc_html_e( 'Street Address Line 1:', 'give' ); ?></strong><br/>
382
-														<input type="text" name="give-payment-address[0][line1]" value="<?php esc_attr_e( $address['line1'] ); ?>" class="medium-text"/>
381
+														<strong class="order-data-address-line"><?php esc_html_e('Street Address Line 1:', 'give'); ?></strong><br/>
382
+														<input type="text" name="give-payment-address[0][line1]" value="<?php esc_attr_e($address['line1']); ?>" class="medium-text"/>
383 383
 													</p>
384 384
 
385 385
 													<p>
386
-														<strong class="order-data-address-line"><?php esc_html_e( 'Street Address Line 2:', 'give' ); ?></strong><br/>
387
-														<input type="text" name="give-payment-address[0][line2]" value="<?php esc_attr_e( $address['line2'] ); ?>" class="medium-text"/>
386
+														<strong class="order-data-address-line"><?php esc_html_e('Street Address Line 2:', 'give'); ?></strong><br/>
387
+														<input type="text" name="give-payment-address[0][line2]" value="<?php esc_attr_e($address['line2']); ?>" class="medium-text"/>
388 388
 													</p>
389 389
 
390 390
 												</div>
391 391
 												<div class="column">
392 392
 													<p>
393
-														<strong class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></strong><br/>
394
-														<input type="text" name="give-payment-address[0][city]" value="<?php esc_attr_e( $address['city'] ); ?>" class="medium-text"/>
393
+														<strong class="order-data-address-line"><?php esc_html_e('City:', 'give'); ?></strong><br/>
394
+														<input type="text" name="give-payment-address[0][city]" value="<?php esc_attr_e($address['city']); ?>" class="medium-text"/>
395 395
 
396 396
 													</p>
397 397
 
398 398
 													<p>
399
-														<strong class="order-data-address-line"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></strong><br/>
400
-														<input type="text" name="give-payment-address[0][zip]" value="<?php esc_attr_e( $address['zip'] ); ?>" class="medium-text"/>
399
+														<strong class="order-data-address-line"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></strong><br/>
400
+														<input type="text" name="give-payment-address[0][zip]" value="<?php esc_attr_e($address['zip']); ?>" class="medium-text"/>
401 401
 
402 402
 													</p>
403 403
 												</div>
404 404
 												<div class="column">
405 405
 													<p id="give-order-address-country-wrap">
406
-														<strong class="order-data-address-line"><?php esc_html_e( 'Country:', 'give' ); ?></strong><br/>
406
+														<strong class="order-data-address-line"><?php esc_html_e('Country:', 'give'); ?></strong><br/>
407 407
 														<?php
408
-														echo Give()->html->select( array(
408
+														echo Give()->html->select(array(
409 409
 															'options'          => give_get_country_list(),
410 410
 															'name'             => 'give-payment-address[0][country]',
411 411
 															'selected'         => $address['country'],
412 412
 															'show_option_all'  => false,
413 413
 															'show_option_none' => false,
414 414
 															'chosen'           => true,
415
-															'placeholder'      => esc_attr( 'Select a country', 'give' )
416
-														) );
415
+															'placeholder'      => esc_attr('Select a country', 'give')
416
+														));
417 417
 														?>
418 418
 													</p>
419 419
 
420 420
 													<p id="give-order-address-state-wrap">
421
-														<strong class="order-data-address-line"><?php esc_html_e( 'State / Province:', 'give' ); ?></strong><br/>
421
+														<strong class="order-data-address-line"><?php esc_html_e('State / Province:', 'give'); ?></strong><br/>
422 422
 														<?php
423
-														$states = give_get_states( $address['country'] );
424
-														if ( ! empty( $states ) ) {
425
-															echo Give()->html->select( array(
423
+														$states = give_get_states($address['country']);
424
+														if ( ! empty($states)) {
425
+															echo Give()->html->select(array(
426 426
 																'options'          => $states,
427 427
 																'name'             => 'give-payment-address[0][state]',
428 428
 																'selected'         => $address['state'],
429 429
 																'show_option_all'  => false,
430 430
 																'show_option_none' => false,
431 431
 																'chosen'           => true,
432
-																'placeholder'      => esc_attr( 'Select a state', 'give' )
433
-															) );
432
+																'placeholder'      => esc_attr('Select a state', 'give')
433
+															));
434 434
 														} else {
435 435
 															?>
436
-															<input type="text" name="give-payment-address[0][state]" value="<?php esc_attr_e( $address['state'] ); ?>" class="medium-text"/>
436
+															<input type="text" name="give-payment-address[0][state]" value="<?php esc_attr_e($address['state']); ?>" class="medium-text"/>
437 437
 															<?php
438 438
 														} ?>
439 439
 													</p>
@@ -443,39 +443,39 @@  discard block
 block discarded – undo
443 443
 									</div>
444 444
 									<!-- /#give-order-address -->
445 445
 
446
-									<?php do_action( 'give_payment_billing_details', $payment_id ); ?>
446
+									<?php do_action('give_payment_billing_details', $payment_id); ?>
447 447
 
448 448
 								</div>
449 449
 								<!-- /.inside -->
450 450
 							</div>
451 451
 							<!-- /#give-billing-details -->
452 452
 
453
-							<?php do_action( 'give_view_order_details_billing_after', $payment_id ); ?>
453
+							<?php do_action('give_view_order_details_billing_after', $payment_id); ?>
454 454
 
455 455
 							<div id="give-payment-notes" class="postbox">
456
-								<h3 class="hndle"><span><?php esc_html_e( 'Payment Notes', 'give' ); ?></span></h3>
456
+								<h3 class="hndle"><span><?php esc_html_e('Payment Notes', 'give'); ?></span></h3>
457 457
 
458 458
 								<div class="inside">
459 459
 									<div id="give-payment-notes-inner">
460 460
 										<?php
461
-										$notes = give_get_payment_notes( $payment_id );
462
-										if ( ! empty( $notes ) ) :
461
+										$notes = give_get_payment_notes($payment_id);
462
+										if ( ! empty($notes)) :
463 463
 											$no_notes_display = ' style="display:none;"';
464
-											foreach ( $notes as $note ) :
464
+											foreach ($notes as $note) :
465 465
 
466
-												echo give_get_payment_note_html( $note, $payment_id );
466
+												echo give_get_payment_note_html($note, $payment_id);
467 467
 
468 468
 											endforeach;
469 469
 										else :
470 470
 											$no_notes_display = '';
471 471
 										endif;
472
-										echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html( 'No payment notes', 'give' ) . '</p>';
472
+										echo '<p class="give-no-payment-notes"'.$no_notes_display.'>'.esc_html('No payment notes', 'give').'</p>';
473 473
 										?>
474 474
 									</div>
475 475
 									<textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea>
476 476
 
477 477
 									<p class="give-clearfix">
478
-										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php esc_html_e( 'Add Note', 'give' ); ?></button>
478
+										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint($payment_id); ?>"><?php esc_html_e('Add Note', 'give'); ?></button>
479 479
 									</p>
480 480
 
481 481
 									<div class="clear"></div>
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 							</div>
485 485
 							<!-- /#give-payment-notes -->
486 486
 
487
-							<?php do_action( 'give_view_order_details_main_after', $payment_id ); ?>
487
+							<?php do_action('give_view_order_details_main_after', $payment_id); ?>
488 488
 						</div>
489 489
 						<!-- /#normal-sortables -->
490 490
 					</div>
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 			<!-- #give-dashboard-widgets-wrap -->
496 496
 		</div>
497 497
 		<!-- /#post-stuff -->
498
-		<?php do_action( 'give_view_order_details_form_bottom', $payment_id ); ?>
499
-		<?php wp_nonce_field( 'give_update_payment_details_nonce' ); ?>
500
-		<input type="hidden" name="give_payment_id" value="<?php esc_attr_e( $payment_id ); ?>"/>
498
+		<?php do_action('give_view_order_details_form_bottom', $payment_id); ?>
499
+		<?php wp_nonce_field('give_update_payment_details_nonce'); ?>
500
+		<input type="hidden" name="give_payment_id" value="<?php esc_attr_e($payment_id); ?>"/>
501 501
 		<input type="hidden" name="give_action" value="update_payment_details"/>
502 502
 	</form>
503
-	<?php do_action( 'give_view_order_details_after', $payment_id ); ?>
503
+	<?php do_action('give_view_order_details_after', $payment_id); ?>
504 504
 </div><!-- /.wrap -->
Please login to merge, or discard this patch.
includes/admin/payments/actions.php 1 patch
Spacing   +96 added lines, -96 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,106 +26,106 @@  discard block
 block discarded – undo
26 26
  * @return      void
27 27
  *
28 28
  */
29
-function give_update_payment_details( $data ) {
29
+function give_update_payment_details($data) {
30 30
 
31
-	if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) {
32
-		wp_die( esc_html( 'You do not have permission to edit payment records.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
31
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
32
+		wp_die(esc_html('You do not have permission to edit payment records.', 'give'), esc_html('Error', 'give'), array('response' => 403));
33 33
 	}
34 34
 
35
-	check_admin_referer( 'give_update_payment_details_nonce' );
35
+	check_admin_referer('give_update_payment_details_nonce');
36 36
 
37 37
 	// Retrieve the payment ID
38
-	$payment_id = absint( $data['give_payment_id'] );
39
-	$payment    = new Give_Payment( $payment_id );
38
+	$payment_id = absint($data['give_payment_id']);
39
+	$payment    = new Give_Payment($payment_id);
40 40
 
41 41
 	// Retrieve existing payment meta
42 42
 	$meta      = $payment->get_meta();
43 43
 	$user_info = $payment->user_info;
44 44
 
45 45
 	$status = $data['give-payment-status'];
46
-	$date   = sanitize_text_field( $data['give-payment-date'] );
47
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
46
+	$date   = sanitize_text_field($data['give-payment-date']);
47
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
48 48
 
49 49
 	// Restrict to our high and low
50
-	if ( $hour > 23 ) {
50
+	if ($hour > 23) {
51 51
 		$hour = 23;
52
-	} elseif ( $hour < 0 ) {
52
+	} elseif ($hour < 0) {
53 53
 		$hour = 00;
54 54
 	}
55 55
 
56
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
56
+	$minute = sanitize_text_field($data['give-payment-time-min']);
57 57
 
58 58
 	// Restrict to our high and low
59
-	if ( $minute > 59 ) {
59
+	if ($minute > 59) {
60 60
 		$minute = 59;
61
-	} elseif ( $minute < 0 ) {
61
+	} elseif ($minute < 0) {
62 62
 		$minute = 00;
63 63
 	}
64 64
 
65
-	$address = array_map( 'trim', $data['give-payment-address'][0] );
65
+	$address = array_map('trim', $data['give-payment-address'][0]);
66 66
 
67
-	$curr_total = give_sanitize_amount( $payment->total );
68
-	$new_total  = give_sanitize_amount( $_POST['give-payment-total'] );
69
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
67
+	$curr_total = give_sanitize_amount($payment->total);
68
+	$new_total  = give_sanitize_amount($_POST['give-payment-total']);
69
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
70 70
 
71
-	$curr_customer_id = sanitize_text_field( $data['give-current-customer'] );
72
-	$new_customer_id  = sanitize_text_field( $data['customer-id'] );
71
+	$curr_customer_id = sanitize_text_field($data['give-current-customer']);
72
+	$new_customer_id  = sanitize_text_field($data['customer-id']);
73 73
 
74
-	do_action( 'give_update_edited_purchase', $payment_id );
74
+	do_action('give_update_edited_purchase', $payment_id);
75 75
 
76 76
 	$payment->date = $date;
77 77
 	$updated       = $payment->save();
78 78
 
79
-	if ( 0 === $updated ) {
80
-		wp_die( esc_html( 'Error Updating Payment.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 400 ) );
79
+	if (0 === $updated) {
80
+		wp_die(esc_html('Error Updating Payment.', 'give'), esc_html('Error', 'give'), array('response' => 400));
81 81
 	}
82 82
 
83 83
 	$customer_changed = false;
84 84
 
85
-	if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) {
85
+	if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') {
86 86
 
87
-		$email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : '';
88
-		$names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : '';
87
+		$email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : '';
88
+		$names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : '';
89 89
 
90
-		if ( empty( $email ) || empty( $names ) ) {
91
-			wp_die( esc_html( 'New Customers require a name and email address.', 'give' ) );
90
+		if (empty($email) || empty($names)) {
91
+			wp_die(esc_html('New Customers require a name and email address.', 'give'));
92 92
 		}
93 93
 
94
-		$customer = new Give_Customer( $email );
95
-		if ( empty( $customer->id ) ) {
96
-			$customer_data = array( 'name' => $names, 'email' => $email );
97
-			$user_id       = email_exists( $email );
98
-			if ( false !== $user_id ) {
94
+		$customer = new Give_Customer($email);
95
+		if (empty($customer->id)) {
96
+			$customer_data = array('name' => $names, 'email' => $email);
97
+			$user_id       = email_exists($email);
98
+			if (false !== $user_id) {
99 99
 				$customer_data['user_id'] = $user_id;
100 100
 			}
101 101
 
102
-			if ( ! $customer->create( $customer_data ) ) {
102
+			if ( ! $customer->create($customer_data)) {
103 103
 				// Failed to crete the new donor, assume the previous donor
104 104
 				$customer_changed = false;
105
-				$customer         = new Give_Customer( $curr_customer_id );
106
-				give_set_error( 'give-payment-new-customer-fail', esc_html( 'Error creating new donor.', 'give' ) );
105
+				$customer         = new Give_Customer($curr_customer_id);
106
+				give_set_error('give-payment-new-customer-fail', esc_html('Error creating new donor.', 'give'));
107 107
 			}
108 108
 		}
109 109
 
110 110
 		$new_customer_id = $customer->id;
111 111
 
112
-		$previous_customer = new Give_Customer( $curr_customer_id );
112
+		$previous_customer = new Give_Customer($curr_customer_id);
113 113
 
114 114
 		$customer_changed = true;
115 115
 
116
-	} elseif ( $curr_customer_id !== $new_customer_id ) {
116
+	} elseif ($curr_customer_id !== $new_customer_id) {
117 117
 
118
-		$customer = new Give_Customer( $new_customer_id );
118
+		$customer = new Give_Customer($new_customer_id);
119 119
 		$email    = $customer->email;
120 120
 		$names    = $customer->name;
121 121
 
122
-		$previous_customer = new Give_Customer( $curr_customer_id );
122
+		$previous_customer = new Give_Customer($curr_customer_id);
123 123
 
124 124
 		$customer_changed = true;
125 125
 
126 126
 	} else {
127 127
 
128
-		$customer = new Give_Customer( $curr_customer_id );
128
+		$customer = new Give_Customer($curr_customer_id);
129 129
 		$email    = $customer->email;
130 130
 		$names    = $customer->name;
131 131
 
@@ -133,29 +133,29 @@  discard block
 block discarded – undo
133 133
 
134 134
 
135 135
 	// Setup first and last name from input values
136
-	$names      = explode( ' ', $names );
137
-	$first_name = ! empty( $names[0] ) ? $names[0] : '';
136
+	$names      = explode(' ', $names);
137
+	$first_name = ! empty($names[0]) ? $names[0] : '';
138 138
 	$last_name  = '';
139
-	if ( ! empty( $names[1] ) ) {
140
-		unset( $names[0] );
141
-		$last_name = implode( ' ', $names );
139
+	if ( ! empty($names[1])) {
140
+		unset($names[0]);
141
+		$last_name = implode(' ', $names);
142 142
 	}
143 143
 
144 144
 
145
-	if ( $customer_changed ) {
145
+	if ($customer_changed) {
146 146
 
147 147
 		// Remove the stats and payment from the previous customer and attach it to the new customer
148
-		$previous_customer->remove_payment( $payment_id, false );
149
-		$customer->attach_payment( $payment_id, false );
148
+		$previous_customer->remove_payment($payment_id, false);
149
+		$customer->attach_payment($payment_id, false);
150 150
 
151 151
 		// If purchase was completed and not ever refunded, adjust stats of customers
152
-		if ( 'revoked' == $status || 'publish' == $status ) {
152
+		if ('revoked' == $status || 'publish' == $status) {
153 153
 
154 154
 			$previous_customer->decrease_purchase_count();
155
-			$previous_customer->decrease_value( $new_total );
155
+			$previous_customer->decrease_value($new_total);
156 156
 
157 157
 			$customer->increase_purchase_count();
158
-			$customer->increase_value( $new_total );
158
+			$customer->increase_value($new_total);
159 159
 		}
160 160
 
161 161
 		$payment->customer_id = $customer->id;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
 
173 173
 	// Check for payment notes
174
-	if ( ! empty( $data['give-payment-note'] ) ) {
174
+	if ( ! empty($data['give-payment-note'])) {
175 175
 
176
-		$note = wp_kses( $data['give-payment-note'], array() );
177
-		give_insert_payment_note( $payment_id, $note );
176
+		$note = wp_kses($data['give-payment-note'], array());
177
+		give_insert_payment_note($payment_id, $note);
178 178
 
179 179
 	}
180 180
 
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 	$payment->status = $status;
183 183
 
184 184
 	// Adjust total store earnings if the payment total has been changed
185
-	if ( $new_total !== $curr_total && ( 'publish' == $status || 'revoked' == $status ) ) {
185
+	if ($new_total !== $curr_total && ('publish' == $status || 'revoked' == $status)) {
186 186
 
187
-		if ( $new_total > $curr_total ) {
187
+		if ($new_total > $curr_total) {
188 188
 			// Increase if our new total is higher
189 189
 			$difference = $new_total - $curr_total;
190
-			give_increase_total_earnings( $difference );
190
+			give_increase_total_earnings($difference);
191 191
 
192
-		} elseif ( $curr_total > $new_total ) {
192
+		} elseif ($curr_total > $new_total) {
193 193
 			// Decrease if our new total is lower
194 194
 			$difference = $curr_total - $new_total;
195
-			give_decrease_total_earnings( $difference );
195
+			give_decrease_total_earnings($difference);
196 196
 
197 197
 		}
198 198
 
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 
201 201
 	$payment->save();
202 202
 
203
-	do_action( 'give_updated_edited_purchase', $payment_id );
203
+	do_action('give_updated_edited_purchase', $payment_id);
204 204
 
205
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) );
205
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id));
206 206
 	exit;
207 207
 }
208 208
 
209
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
209
+add_action('give_update_payment_details', 'give_update_payment_details');
210 210
 
211 211
 /**
212 212
  * Trigger a Purchase Deletion
@@ -217,48 +217,48 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return void
219 219
  */
220
-function give_trigger_purchase_delete( $data ) {
221
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) {
220
+function give_trigger_purchase_delete($data) {
221
+	if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) {
222 222
 
223
-		$payment_id = absint( $data['purchase_id'] );
223
+		$payment_id = absint($data['purchase_id']);
224 224
 
225
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
226
-			wp_die( esc_html( 'You do not have permission to edit payment records.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
225
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
226
+			wp_die(esc_html('You do not have permission to edit payment records.', 'give'), esc_html('Error', 'give'), array('response' => 403));
227 227
 		}
228 228
 
229
-		give_delete_purchase( $payment_id );
230
-		wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) );
229
+		give_delete_purchase($payment_id);
230
+		wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted'));
231 231
 		give_die();
232 232
 	}
233 233
 }
234 234
 
235
-add_action( 'give_delete_payment', 'give_trigger_purchase_delete' );
235
+add_action('give_delete_payment', 'give_trigger_purchase_delete');
236 236
 
237 237
 /**
238 238
  * AJAX Store Payment Note
239 239
  */
240 240
 function give_ajax_store_payment_note() {
241 241
 
242
-	$payment_id = absint( $_POST['payment_id'] );
243
-	$note       = wp_kses( $_POST['note'], array() );
242
+	$payment_id = absint($_POST['payment_id']);
243
+	$note       = wp_kses($_POST['note'], array());
244 244
 
245
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
246
-		wp_die( esc_html( 'You do not have permission to edit payment records.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
245
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
246
+		wp_die(esc_html('You do not have permission to edit payment records.', 'give'), esc_html('Error', 'give'), array('response' => 403));
247 247
 	}
248 248
 
249
-	if ( empty( $payment_id ) ) {
250
-		die( '-1' );
249
+	if (empty($payment_id)) {
250
+		die('-1');
251 251
 	}
252 252
 
253
-	if ( empty( $note ) ) {
254
-		die( '-1' );
253
+	if (empty($note)) {
254
+		die('-1');
255 255
 	}
256 256
 
257
-	$note_id = give_insert_payment_note( $payment_id, $note );
258
-	die( give_get_payment_note_html( $note_id ) );
257
+	$note_id = give_insert_payment_note($payment_id, $note);
258
+	die(give_get_payment_note_html($note_id));
259 259
 }
260 260
 
261
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
261
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
262 262
 
263 263
 /**
264 264
  * Triggers a payment note deletion without ajax
@@ -269,24 +269,24 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return void
271 271
  */
272
-function give_trigger_payment_note_deletion( $data ) {
272
+function give_trigger_payment_note_deletion($data) {
273 273
 
274
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
274
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
275 275
 		return;
276 276
 	}
277 277
 
278
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
279
-		wp_die( esc_html( 'You do not have permission to edit payment records.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
278
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
279
+		wp_die(esc_html('You do not have permission to edit payment records.', 'give'), esc_html('Error', 'give'), array('response' => 403));
280 280
 	}
281 281
 
282
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) );
282
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id']));
283 283
 
284
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
284
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
285 285
 
286
-	wp_redirect( $edit_order_url );
286
+	wp_redirect($edit_order_url);
287 287
 }
288 288
 
289
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
289
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
290 290
 
291 291
 /**
292 292
  * Delete a payment note deletion with ajax
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function give_ajax_delete_payment_note() {
301 301
 
302
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
303
-		wp_die( esc_html( 'You do not have permission to edit payment records.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) );
302
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
303
+		wp_die(esc_html('You do not have permission to edit payment records.', 'give'), esc_html('Error', 'give'), array('response' => 403));
304 304
 	}
305 305
 
306
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
307
-		die( '1' );
306
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
307
+		die('1');
308 308
 	} else {
309
-		die( '-1' );
309
+		die('-1');
310 310
 	}
311 311
 
312 312
 }
313 313
 
314
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
315 314
\ No newline at end of file
315
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
316 316
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/payments/payments-history.php 1 patch
Spacing   +21 added lines, -21 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' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Payment History Page
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 function give_payment_history_page() {
25 25
 	global $give_options;
26 26
 
27
-	$give_payment = get_post_type_object( 'give_payment' );
27
+	$give_payment = get_post_type_object('give_payment');
28 28
 
29
-	if ( isset( $_GET['view'] ) && 'view-order-details' == $_GET['view'] ) {
30
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-order-details.php';
29
+	if (isset($_GET['view']) && 'view-order-details' == $_GET['view']) {
30
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-order-details.php';
31 31
 	} else {
32
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
32
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
33 33
 		$payments_table = new Give_Payment_History_Table();
34 34
 		$payments_table->prepare_items();
35 35
 	?>
36 36
 	<div class="wrap">
37 37
 		<h2><?php echo $give_payment->labels->menu_name ?></h2>
38
-		<?php do_action( 'give_payments_page_top' ); ?>
39
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
38
+		<?php do_action('give_payments_page_top'); ?>
39
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
40 40
 			<input type="hidden" name="post_type" value="give_forms" />
41 41
 			<input type="hidden" name="page" value="give-payment-history" />
42 42
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			
47 47
 			<?php $payments_table->display() ?>
48 48
 		</form>
49
-		<?php do_action( 'give_payments_page_bottom' ); ?>
49
+		<?php do_action('give_payments_page_bottom'); ?>
50 50
 	</div>
51 51
 <?php
52 52
 	}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
  * @param $title
62 62
  * @return string
63 63
  */
64
-function give_view_order_details_title( $admin_title, $title ) {
64
+function give_view_order_details_title($admin_title, $title) {
65 65
 
66
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base )
66
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base)
67 67
 		return $admin_title;
68 68
 
69
-	if( ! isset( $_GET['give-action'] ) )
69
+	if ( ! isset($_GET['give-action']))
70 70
 		return $admin_title;
71 71
 
72
-	switch( $_GET['give-action'] ) :
72
+	switch ($_GET['give-action']) :
73 73
 
74 74
 		case 'view-order-details' :
75
-			$title = esc_html( 'View Donation Details', 'give' ) . ' - ' . $admin_title;
75
+			$title = esc_html('View Donation Details', 'give').' - '.$admin_title;
76 76
 			break;
77 77
 		case 'edit-payment' :
78
-			$title = esc_html( 'Edit Payment', 'give' ) . ' - ' . $admin_title;
78
+			$title = esc_html('Edit Payment', 'give').' - '.$admin_title;
79 79
 			break;
80 80
 		default:
81 81
 			$title = $admin_title;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	return $title;
86 86
 }
87
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
87
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
88 88
 
89 89
 /**
90 90
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
  * @param $context
97 97
  * @return string
98 98
  */
99
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
99
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
100 100
 
101
-	$post = get_post( $post_id );
102
-	if( ! $post )
101
+	$post = get_post($post_id);
102
+	if ( ! $post)
103 103
 		return $url;
104 104
 
105
-	if( 'give_payment' != $post->post_type )
105
+	if ('give_payment' != $post->post_type)
106 106
 		return $url;
107 107
 
108
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $post_id );
108
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$post_id);
109 109
 
110 110
 	return $url;
111 111
 }
112
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
112
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.
includes/admin/payments/class-payments-table.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
 		global $status, $page;
121 121
 
122 122
 		// Set parent defaults
123
-		parent::__construct( array(
124
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
125
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
123
+		parent::__construct(array(
124
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
125
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
126 126
 			'ajax'     => false                        // Does this table support ajax?
127
-		) );
127
+		));
128 128
 
129 129
 		$this->get_payment_counts();
130 130
 		$this->process_bulk_action();
131
-		$this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
131
+		$this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
132 132
 	}
133 133
 
134 134
 	public function advanced_filters() {
135
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
136
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null;
137
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : '';
135
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
136
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null;
137
+		$status     = isset($_GET['status']) ? $_GET['status'] : '';
138 138
 		?>
139 139
 		<div id="give-payment-filters">
140 140
 			<span id="give-payment-date-filters">
141
-				<label for="start-date" class="give-start-date-label"><?php esc_html_e( 'Start Date:', 'give' ); ?></label>
141
+				<label for="start-date" class="give-start-date-label"><?php esc_html_e('Start Date:', 'give'); ?></label>
142 142
 				<input type="text" id="start-date" name="start-date" class="give_datepicker" value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/>
143
-				<label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date:', 'give' ); ?></label>
143
+				<label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date:', 'give'); ?></label>
144 144
 				<input type="text" id="end-date" name="end-date" class="give_datepicker" value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/>
145
-				<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Apply', 'give' ); ?>"/>
145
+				<input type="submit" class="button-secondary" value="<?php esc_attr_e('Apply', 'give'); ?>"/>
146 146
 			</span>
147
-			<?php if ( ! empty( $status ) ) : ?>
148
-				<input type="hidden" name="status" value="<?php esc_attr_e( $status ); ?>"/>
147
+			<?php if ( ! empty($status)) : ?>
148
+				<input type="hidden" name="status" value="<?php esc_attr_e($status); ?>"/>
149 149
 			<?php endif; ?>
150
-			<?php if ( ! empty( $start_date ) || ! empty( $end_date ) ) : ?>
151
-				<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" class="button-secondary"><?php esc_html_e( 'Clear Filter', 'give' ); ?></a>
150
+			<?php if ( ! empty($start_date) || ! empty($end_date)) : ?>
151
+				<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" class="button-secondary"><?php esc_html_e('Clear Filter', 'give'); ?></a>
152 152
 			<?php endif; ?>
153
-			<?php $this->search_box( esc_html( 'Search', 'give' ), 'give-payments' ); ?>
153
+			<?php $this->search_box(esc_html('Search', 'give'), 'give-payments'); ?>
154 154
 		</div>
155 155
 
156 156
 		<?php
@@ -167,25 +167,25 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return void
169 169
 	 */
170
-	public function search_box( $text, $input_id ) {
171
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
170
+	public function search_box($text, $input_id) {
171
+		if (empty($_REQUEST['s']) && ! $this->has_items()) {
172 172
 			return;
173 173
 		}
174 174
 
175
-		$input_id = $input_id . '-search-input';
175
+		$input_id = $input_id.'-search-input';
176 176
 
177
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
178
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
177
+		if ( ! empty($_REQUEST['orderby'])) {
178
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
179 179
 		}
180
-		if ( ! empty( $_REQUEST['order'] ) ) {
181
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
180
+		if ( ! empty($_REQUEST['order'])) {
181
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
182 182
 		}
183 183
 		?>
184 184
 		<p class="search-box">
185
-			<?php do_action( 'give_payment_history_search' ); ?>
185
+			<?php do_action('give_payment_history_search'); ?>
186 186
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
187 187
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
188
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?><br/>
188
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/>
189 189
 		</p>
190 190
 		<?php
191 191
 	}
@@ -199,52 +199,52 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function get_views() {
201 201
 
202
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
203
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count . ')</span>';
204
-		$complete_count  = '&nbsp;<span class="count">(' . $this->complete_count . ')</span>';
205
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count . ')</span>';
206
-		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
207
-		$refunded_count  = '&nbsp;<span class="count">(' . $this->refunded_count . ')</span>';
208
-		$failed_count    = '&nbsp;<span class="count">(' . $this->failed_count . ')</span>';
209
-		$abandoned_count = '&nbsp;<span class="count">(' . $this->abandoned_count . ')</span>';
210
-		$revoked_count   = '&nbsp;<span class="count">(' . $this->revoked_count . ')</span>';
202
+		$current         = isset($_GET['status']) ? $_GET['status'] : '';
203
+		$total_count     = '&nbsp;<span class="count">('.$this->total_count.')</span>';
204
+		$complete_count  = '&nbsp;<span class="count">('.$this->complete_count.')</span>';
205
+		$cancelled_count = '&nbsp;<span class="count">('.$this->cancelled_count.')</span>';
206
+		$pending_count   = '&nbsp;<span class="count">('.$this->pending_count.')</span>';
207
+		$refunded_count  = '&nbsp;<span class="count">('.$this->refunded_count.')</span>';
208
+		$failed_count    = '&nbsp;<span class="count">('.$this->failed_count.')</span>';
209
+		$abandoned_count = '&nbsp;<span class="count">('.$this->abandoned_count.')</span>';
210
+		$revoked_count   = '&nbsp;<span class="count">('.$this->revoked_count.')</span>';
211 211
 
212 212
 		$views = array(
213
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array(
213
+			'all'       => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array(
214 214
 				'status',
215 215
 				'paged'
216
-			) ), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html( 'All', 'give' ) . $total_count ),
217
-			'publish'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
216
+			)), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html('All', 'give').$total_count),
217
+			'publish'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
218 218
 				'status' => 'publish',
219 219
 				'paged'  => false
220
-			) ) ), $current === 'publish' ? ' class="current"' : '', esc_html( 'Completed', 'give' ) . $complete_count ),
221
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
220
+			))), $current === 'publish' ? ' class="current"' : '', esc_html('Completed', 'give').$complete_count),
221
+			'pending'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
222 222
 				'status' => 'pending',
223 223
 				'paged'  => false
224
-			) ) ), $current === 'pending' ? ' class="current"' : '', esc_html( 'Pending', 'give' ) . $pending_count ),
225
-			'refunded'  => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
224
+			))), $current === 'pending' ? ' class="current"' : '', esc_html('Pending', 'give').$pending_count),
225
+			'refunded'  => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
226 226
 				'status' => 'refunded',
227 227
 				'paged'  => false
228
-			) ) ), $current === 'refunded' ? ' class="current"' : '', esc_html( 'Refunded', 'give' ) . $refunded_count ),
229
-			'revoked'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
228
+			))), $current === 'refunded' ? ' class="current"' : '', esc_html('Refunded', 'give').$refunded_count),
229
+			'revoked'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
230 230
 				'status' => 'revoked',
231 231
 				'paged'  => false
232
-			) ) ), $current === 'revoked' ? ' class="current"' : '', esc_html( 'Revoked', 'give' ) . $revoked_count ),
233
-			'failed'    => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
232
+			))), $current === 'revoked' ? ' class="current"' : '', esc_html('Revoked', 'give').$revoked_count),
233
+			'failed'    => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
234 234
 				'status' => 'failed',
235 235
 				'paged'  => false
236
-			) ) ), $current === 'failed' ? ' class="current"' : '', esc_html( 'Failed', 'give' ) . $failed_count ),
237
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
236
+			))), $current === 'failed' ? ' class="current"' : '', esc_html('Failed', 'give').$failed_count),
237
+			'cancelled' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
238 238
 				'status' => 'cancelled',
239 239
 				'paged'  => false
240
-			) ) ), $current === 'cancelled' ? ' class="current"' : '', esc_html( 'Cancelled', 'give' ) . $cancelled_count ),
241
-			'abandoned' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
240
+			))), $current === 'cancelled' ? ' class="current"' : '', esc_html('Cancelled', 'give').$cancelled_count),
241
+			'abandoned' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
242 242
 				'status' => 'abandoned',
243 243
 				'paged'  => false
244
-			) ) ), $current === 'abandoned' ? ' class="current"' : '', esc_html( 'Abandoned', 'give' ) . $abandoned_count )
244
+			))), $current === 'abandoned' ? ' class="current"' : '', esc_html('Abandoned', 'give').$abandoned_count)
245 245
 		);
246 246
 
247
-		return apply_filters( 'give_payments_table_views', $views );
247
+		return apply_filters('give_payments_table_views', $views);
248 248
 	}
249 249
 
250 250
 	/**
@@ -257,17 +257,17 @@  discard block
 block discarded – undo
257 257
 	public function get_columns() {
258 258
 		$columns = array(
259 259
 			'cb'       => '<input type="checkbox" />', //Render a checkbox instead of text
260
-			'email'    => esc_html( 'Email', 'give' ),
261
-			'details'  => esc_html( 'Details', 'give' ),
262
-			'amount'   => esc_html( 'Amount', 'give' ),
263
-			'donation' => esc_html( 'Donation', 'give' ),
264
-			'status'   => esc_html( 'Status', 'give' ),
265
-			'date'     => esc_html( 'Date', 'give' ),
266
-			'donor'    => esc_html( 'Donor', 'give' ),
267
-			'ID'       => esc_html( 'ID', 'give' ),
260
+			'email'    => esc_html('Email', 'give'),
261
+			'details'  => esc_html('Details', 'give'),
262
+			'amount'   => esc_html('Amount', 'give'),
263
+			'donation' => esc_html('Donation', 'give'),
264
+			'status'   => esc_html('Status', 'give'),
265
+			'date'     => esc_html('Date', 'give'),
266
+			'donor'    => esc_html('Donor', 'give'),
267
+			'ID'       => esc_html('ID', 'give'),
268 268
 		);
269 269
 
270
-		return apply_filters( 'give_payments_table_columns', $columns );
270
+		return apply_filters('give_payments_table_columns', $columns);
271 271
 	}
272 272
 
273 273
 	/**
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function get_sortable_columns() {
281 281
 		$columns = array(
282
-			'ID'     => array( 'ID', true ),
283
-			'amount' => array( 'amount', false ),
284
-			'date'   => array( 'date', false )
282
+			'ID'     => array('ID', true),
283
+			'amount' => array('amount', false),
284
+			'date'   => array('date', false)
285 285
 		);
286 286
 
287
-		return apply_filters( 'give_payments_table_sortable_columns', $columns );
287
+		return apply_filters('give_payments_table_sortable_columns', $columns);
288 288
 	}
289 289
 
290 290
 	/**
@@ -310,41 +310,41 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @return string Column Name
312 312
 	 */
313
-	public function column_default( $payment, $column_name ) {
314
-		switch ( $column_name ) {
313
+	public function column_default($payment, $column_name) {
314
+		switch ($column_name) {
315 315
 			case 'amount' :
316
-				$amount = ! empty( $payment->total ) ? $payment->total : 0;
317
-				$value  = give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment->ID ) );
316
+				$amount = ! empty($payment->total) ? $payment->total : 0;
317
+				$value  = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID));
318 318
 				break;
319 319
 			case 'donation' :
320
-				$value = '<a href="' . get_permalink( $payment->form_id ) . '">' . $payment->form_title . '</a>';
321
-				$level = give_get_payment_form_title( $payment->meta, true );
320
+				$value = '<a href="'.get_permalink($payment->form_id).'">'.$payment->form_title.'</a>';
321
+				$level = give_get_payment_form_title($payment->meta, true);
322 322
 
323
-				if ( ! empty( $level ) ) {
323
+				if ( ! empty($level)) {
324 324
 					$value .= $level;
325 325
 				}
326 326
 
327 327
 				break;
328 328
 			case 'date' :
329
-				$date  = strtotime( $payment->date );
330
-				$value = date_i18n( get_option( 'date_format' ), $date );
329
+				$date  = strtotime($payment->date);
330
+				$value = date_i18n(get_option('date_format'), $date);
331 331
 				break;
332 332
 			case 'status' :
333
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
334
-				if ( $payment->mode == 'test' ) {
335
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr( 'This payment was made in test mode', 'give' ) . '">' . esc_html( 'Test', 'give' ) . '</span>';
333
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
334
+				if ($payment->mode == 'test') {
335
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr('This payment was made in test mode', 'give').'">'.esc_html('Test', 'give').'</span>';
336 336
 				}
337 337
 				break;
338 338
 			case 'details' :
339
-				$value = '<div class="give-payment-details-link-wrap"><a href="' . esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details' ) ) ) . '" class="give-payment-details-link button button-small">' . esc_html( 'View Details', 'give' ) . '</a></div>';
339
+				$value = '<div class="give-payment-details-link-wrap"><a href="'.esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details'))).'" class="give-payment-details-link button button-small">'.esc_html('View Details', 'give').'</a></div>';
340 340
 				break;
341 341
 			default:
342
-				$value = isset( $payment->$column_name ) ? $payment->$column_name : '';
342
+				$value = isset($payment->$column_name) ? $payment->$column_name : '';
343 343
 				break;
344 344
 
345 345
 		}
346 346
 
347
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name );
347
+		return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
348 348
 	}
349 349
 
350 350
 	/**
@@ -357,40 +357,40 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @return string Data shown in the Email column
359 359
 	 */
360
-	public function column_email( $payment ) {
360
+	public function column_email($payment) {
361 361
 
362 362
 		$row_actions = array();
363 363
 
364
-		$email = give_get_payment_user_email( $payment->ID );
364
+		$email = give_get_payment_user_email($payment->ID);
365 365
 
366 366
 		// Add search term string back to base URL
367
-		$search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' );
368
-		if ( ! empty( $search_terms ) ) {
369
-			$this->base_url = add_query_arg( 's', $search_terms, $this->base_url );
367
+		$search_terms = (isset($_GET['s']) ? trim($_GET['s']) : '');
368
+		if ( ! empty($search_terms)) {
369
+			$this->base_url = add_query_arg('s', $search_terms, $this->base_url);
370 370
 		}
371 371
 
372
-		if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) {
373
-			$row_actions['email_links'] = '<a href="' . add_query_arg( array(
372
+		if (give_is_payment_complete($payment->ID) && ! empty($email)) {
373
+			$row_actions['email_links'] = '<a href="'.add_query_arg(array(
374 374
 					'give-action' => 'email_links',
375 375
 					'purchase_id' => $payment->ID
376
-				), $this->base_url ) . '">' . esc_html( 'Resend Donation Receipt', 'give' ) . '</a>';
376
+				), $this->base_url).'">'.esc_html('Resend Donation Receipt', 'give').'</a>';
377 377
 
378 378
 		}
379 379
 
380
-		$row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array(
380
+		$row_actions['delete'] = '<a href="'.wp_nonce_url(add_query_arg(array(
381 381
 				'give-action' => 'delete_payment',
382 382
 				'purchase_id' => $payment->ID
383
-			), $this->base_url ), 'give_payment_nonce' ) . '">' . esc_html( 'Delete', 'give' ) . '</a>';
383
+			), $this->base_url), 'give_payment_nonce').'">'.esc_html('Delete', 'give').'</a>';
384 384
 
385
-		$row_actions = apply_filters( 'give_payment_row_actions', $row_actions, $payment );
385
+		$row_actions = apply_filters('give_payment_row_actions', $row_actions, $payment);
386 386
 
387
-		if ( empty( $email ) ) {
388
-			$email = esc_html( '(unknown)', 'give' );
387
+		if (empty($email)) {
388
+			$email = esc_html('(unknown)', 'give');
389 389
 		}
390 390
 
391
-		$value = '<span class="give-email-column-value">' . $email . '</span>' . $this->row_actions( $row_actions );
391
+		$value = '<span class="give-email-column-value">'.$email.'</span>'.$this->row_actions($row_actions);
392 392
 
393
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' );
393
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'email');
394 394
 	}
395 395
 
396 396
 	/**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return string Displays a checkbox
405 405
 	 */
406
-	public function column_cb( $payment ) {
406
+	public function column_cb($payment) {
407 407
 		return sprintf(
408 408
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
409 409
 			'payment',
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @return string Displays a checkbox
423 423
 	 */
424
-	public function column_ID( $payment ) {
425
-		return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>';
424
+	public function column_ID($payment) {
425
+		return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>';
426 426
 	}
427 427
 
428 428
 	/**
@@ -435,19 +435,19 @@  discard block
 block discarded – undo
435 435
 	 *
436 436
 	 * @return string Data shown in the User column
437 437
 	 */
438
-	public function column_donor( $payment ) {
438
+	public function column_donor($payment) {
439 439
 
440
-		$customer_id = give_get_payment_customer_id( $payment->ID );
440
+		$customer_id = give_get_payment_customer_id($payment->ID);
441 441
 
442
-		if ( ! empty( $customer_id ) ) {
443
-			$customer = new Give_Customer( $customer_id );
444
-			$value    = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id" ) ) . '">' . $customer->name . '</a>';
442
+		if ( ! empty($customer_id)) {
443
+			$customer = new Give_Customer($customer_id);
444
+			$value    = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id")).'">'.$customer->name.'</a>';
445 445
 		} else {
446
-			$email = give_get_payment_user_email( $payment->ID );
447
-			$value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html( '(donor missing)', 'give' ) . '</a>';
446
+			$email = give_get_payment_user_email($payment->ID);
447
+			$value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html('(donor missing)', 'give').'</a>';
448 448
 		}
449 449
 
450
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' );
450
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor');
451 451
 	}
452 452
 
453 453
 	/**
@@ -459,18 +459,18 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function get_bulk_actions() {
461 461
 		$actions = array(
462
-			'delete'               => esc_html( 'Delete', 'give' ),
463
-			'set-status-publish'   => esc_html( 'Set To Completed', 'give' ),
464
-			'set-status-pending'   => esc_html( 'Set To Pending', 'give' ),
465
-			'set-status-refunded'  => esc_html( 'Set To Refunded', 'give' ),
466
-			'set-status-revoked'   => esc_html( 'Set To Revoked', 'give' ),
467
-			'set-status-failed'    => esc_html( 'Set To Failed', 'give' ),
468
-			'set-status-cancelled' => esc_html( 'Set To Cancelled', 'give' ),
469
-			'set-status-abandoned' => esc_html( 'Set To Abandoned', 'give' ),
470
-			'resend-receipt'       => esc_html( 'Resend Email Receipts', 'give' )
462
+			'delete'               => esc_html('Delete', 'give'),
463
+			'set-status-publish'   => esc_html('Set To Completed', 'give'),
464
+			'set-status-pending'   => esc_html('Set To Pending', 'give'),
465
+			'set-status-refunded'  => esc_html('Set To Refunded', 'give'),
466
+			'set-status-revoked'   => esc_html('Set To Revoked', 'give'),
467
+			'set-status-failed'    => esc_html('Set To Failed', 'give'),
468
+			'set-status-cancelled' => esc_html('Set To Cancelled', 'give'),
469
+			'set-status-abandoned' => esc_html('Set To Abandoned', 'give'),
470
+			'resend-receipt'       => esc_html('Resend Email Receipts', 'give')
471 471
 		);
472 472
 
473
-		return apply_filters( 'give_payments_table_bulk_actions', $actions );
473
+		return apply_filters('give_payments_table_bulk_actions', $actions);
474 474
 	}
475 475
 
476 476
 	/**
@@ -481,61 +481,61 @@  discard block
 block discarded – undo
481 481
 	 * @return void
482 482
 	 */
483 483
 	public function process_bulk_action() {
484
-		$ids    = isset( $_GET['payment'] ) ? $_GET['payment'] : false;
484
+		$ids    = isset($_GET['payment']) ? $_GET['payment'] : false;
485 485
 		$action = $this->current_action();
486 486
 
487
-		if ( ! is_array( $ids ) ) {
488
-			$ids = array( $ids );
487
+		if ( ! is_array($ids)) {
488
+			$ids = array($ids);
489 489
 		}
490 490
 
491
-		if ( empty( $action ) ) {
491
+		if (empty($action)) {
492 492
 			return;
493 493
 		}
494 494
 
495
-		foreach ( $ids as $id ) {
495
+		foreach ($ids as $id) {
496 496
 
497 497
 			// Detect when a bulk action is being triggered...
498
-			if ( 'delete' === $this->current_action() ) {
499
-				give_delete_purchase( $id );
498
+			if ('delete' === $this->current_action()) {
499
+				give_delete_purchase($id);
500 500
 			}
501 501
 
502
-			if ( 'set-status-publish' === $this->current_action() ) {
503
-				give_update_payment_status( $id, 'publish' );
502
+			if ('set-status-publish' === $this->current_action()) {
503
+				give_update_payment_status($id, 'publish');
504 504
 			}
505 505
 
506
-			if ( 'set-status-pending' === $this->current_action() ) {
507
-				give_update_payment_status( $id, 'pending' );
506
+			if ('set-status-pending' === $this->current_action()) {
507
+				give_update_payment_status($id, 'pending');
508 508
 			}
509 509
 
510
-			if ( 'set-status-refunded' === $this->current_action() ) {
511
-				give_update_payment_status( $id, 'refunded' );
510
+			if ('set-status-refunded' === $this->current_action()) {
511
+				give_update_payment_status($id, 'refunded');
512 512
 			}
513 513
 
514
-			if ( 'set-status-revoked' === $this->current_action() ) {
515
-				give_update_payment_status( $id, 'revoked' );
514
+			if ('set-status-revoked' === $this->current_action()) {
515
+				give_update_payment_status($id, 'revoked');
516 516
 			}
517 517
 
518
-			if ( 'set-status-failed' === $this->current_action() ) {
519
-				give_update_payment_status( $id, 'failed' );
518
+			if ('set-status-failed' === $this->current_action()) {
519
+				give_update_payment_status($id, 'failed');
520 520
 			}
521 521
 
522
-			if ( 'set-status-cancelled' === $this->current_action() ) {
523
-				give_update_payment_status( $id, 'cancelled' );
522
+			if ('set-status-cancelled' === $this->current_action()) {
523
+				give_update_payment_status($id, 'cancelled');
524 524
 			}
525 525
 
526
-			if ( 'set-status-abandoned' === $this->current_action() ) {
527
-				give_update_payment_status( $id, 'abandoned' );
526
+			if ('set-status-abandoned' === $this->current_action()) {
527
+				give_update_payment_status($id, 'abandoned');
528 528
 			}
529 529
 
530
-			if ( 'set-status-preapproval' === $this->current_action() ) {
531
-				give_update_payment_status( $id, 'preapproval' );
530
+			if ('set-status-preapproval' === $this->current_action()) {
531
+				give_update_payment_status($id, 'preapproval');
532 532
 			}
533 533
 
534
-			if ( 'resend-receipt' === $this->current_action() ) {
535
-				give_email_donation_receipt( $id, false );
534
+			if ('resend-receipt' === $this->current_action()) {
535
+				give_email_donation_receipt($id, false);
536 536
 			}
537 537
 
538
-			do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() );
538
+			do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
539 539
 		}
540 540
 
541 541
 	}
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
 
554 554
 		$args = array();
555 555
 
556
-		if ( isset( $_GET['user'] ) ) {
557
-			$args['user'] = urldecode( $_GET['user'] );
558
-		} elseif ( isset( $_GET['s'] ) ) {
559
-			$is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false;
560
-			if ( $is_user ) {
561
-				$args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) );
562
-				unset( $args['s'] );
556
+		if (isset($_GET['user'])) {
557
+			$args['user'] = urldecode($_GET['user']);
558
+		} elseif (isset($_GET['s'])) {
559
+			$is_user = strpos($_GET['s'], strtolower('user:')) !== false;
560
+			if ($is_user) {
561
+				$args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s']))));
562
+				unset($args['s']);
563 563
 			} else {
564
-				$args['s'] = sanitize_text_field( $_GET['s'] );
564
+				$args['s'] = sanitize_text_field($_GET['s']);
565 565
 			}
566 566
 		}
567 567
 
568
-		if ( ! empty( $_GET['start-date'] ) ) {
569
-			$args['start-date'] = urldecode( $_GET['start-date'] );
568
+		if ( ! empty($_GET['start-date'])) {
569
+			$args['start-date'] = urldecode($_GET['start-date']);
570 570
 		}
571 571
 
572
-		if ( ! empty( $_GET['end-date'] ) ) {
573
-			$args['end-date'] = urldecode( $_GET['end-date'] );
572
+		if ( ! empty($_GET['end-date'])) {
573
+			$args['end-date'] = urldecode($_GET['end-date']);
574 574
 		}
575 575
 
576
-		$payment_count         = give_count_payments( $args );
576
+		$payment_count         = give_count_payments($args);
577 577
 		$this->complete_count  = $payment_count->publish;
578 578
 		$this->pending_count   = $payment_count->pending;
579 579
 		$this->refunded_count  = $payment_count->refunded;
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		$this->cancelled_count = $payment_count->cancelled;
583 583
 		$this->abandoned_count = $payment_count->abandoned;
584 584
 
585
-		foreach ( $payment_count as $count ) {
585
+		foreach ($payment_count as $count) {
586 586
 			$this->total_count += $count;
587 587
 		}
588 588
 	}
@@ -597,26 +597,26 @@  discard block
 block discarded – undo
597 597
 	public function payments_data() {
598 598
 
599 599
 		$per_page   = $this->per_page;
600
-		$orderby    = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID';
601
-		$order      = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
602
-		$user       = isset( $_GET['user'] ) ? $_GET['user'] : null;
603
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys();
604
-		$meta_key   = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null;
605
-		$year       = isset( $_GET['year'] ) ? $_GET['year'] : null;
606
-		$month      = isset( $_GET['m'] ) ? $_GET['m'] : null;
607
-		$day        = isset( $_GET['day'] ) ? $_GET['day'] : null;
608
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null;
609
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
610
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date;
611
-
612
-		if ( ! empty( $search ) ) {
600
+		$orderby    = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID';
601
+		$order      = isset($_GET['order']) ? $_GET['order'] : 'DESC';
602
+		$user       = isset($_GET['user']) ? $_GET['user'] : null;
603
+		$status     = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys();
604
+		$meta_key   = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
605
+		$year       = isset($_GET['year']) ? $_GET['year'] : null;
606
+		$month      = isset($_GET['m']) ? $_GET['m'] : null;
607
+		$day        = isset($_GET['day']) ? $_GET['day'] : null;
608
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
609
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
610
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date;
611
+
612
+		if ( ! empty($search)) {
613 613
 			$status = 'any'; // Force all payment statuses when searching
614 614
 		}
615 615
 
616 616
 		$args = array(
617 617
 			'output'     => 'payments',
618 618
 			'number'     => $per_page,
619
-			'page'       => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
619
+			'page'       => isset($_GET['paged']) ? $_GET['paged'] : null,
620 620
 			'orderby'    => $orderby,
621 621
 			'order'      => $order,
622 622
 			'user'       => $user,
@@ -630,14 +630,14 @@  discard block
 block discarded – undo
630 630
 			'end_date'   => $end_date,
631 631
 		);
632 632
 
633
-		if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) {
633
+		if (is_string($search) && false !== strpos($search, 'txn:')) {
634 634
 
635 635
 			$args['search_in_notes'] = true;
636
-			$args['s']               = trim( str_replace( 'txn:', '', $args['s'] ) );
636
+			$args['s']               = trim(str_replace('txn:', '', $args['s']));
637 637
 
638 638
 		}
639 639
 
640
-		$p_query = new Give_Payments_Query( $args );
640
+		$p_query = new Give_Payments_Query($args);
641 641
 
642 642
 		return $p_query->get_payments();
643 643
 
@@ -657,17 +657,17 @@  discard block
 block discarded – undo
657 657
 	 */
658 658
 	public function prepare_items() {
659 659
 
660
-		wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) );
660
+		wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's'));
661 661
 
662 662
 		$columns  = $this->get_columns();
663 663
 		$hidden   = array(); // No hidden columns
664 664
 		$sortable = $this->get_sortable_columns();
665 665
 		$data     = $this->payments_data();
666
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
666
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
667 667
 
668
-		$this->_column_headers = array( $columns, $hidden, $sortable );
668
+		$this->_column_headers = array($columns, $hidden, $sortable);
669 669
 
670
-		switch ( $status ) {
670
+		switch ($status) {
671 671
 			case 'publish':
672 672
 				$total_items = $this->complete_count;
673 673
 				break;
@@ -694,18 +694,18 @@  discard block
 block discarded – undo
694 694
 				break;
695 695
 			default:
696 696
 				// Retrieve the count of the non-default-Give status
697
-				$count       = wp_count_posts( 'give_payment' );
697
+				$count       = wp_count_posts('give_payment');
698 698
 				$total_items = $count->{$status};
699 699
 		}
700 700
 
701 701
 		$this->items = $data;
702 702
 
703
-		$this->set_pagination_args( array(
703
+		$this->set_pagination_args(array(
704 704
 				'total_items' => $total_items,
705 705
 				// WE have to calculate the total number of items
706 706
 				'per_page'    => $this->per_page,
707 707
 				// WE have to determine how many items to show on a page
708
-				'total_pages' => ceil( $total_items / $this->per_page )
708
+				'total_pages' => ceil($total_items / $this->per_page)
709 709
 				// WE have to calculate the total number of pages
710 710
 			)
711 711
 		);
Please login to merge, or discard this patch.
includes/admin/plugins.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return array $links
28 28
  */
29
-function give_plugin_action_links( $links, $file ) {
30
-	$settings_link = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings' ) . '">' . esc_html( 'Settings', 'give' ) . '</a>';
31
-	if ( $file == 'give/give.php' ) {
32
-		array_unshift( $links, $settings_link );
29
+function give_plugin_action_links($links, $file) {
30
+	$settings_link = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings').'">'.esc_html('Settings', 'give').'</a>';
31
+	if ($file == 'give/give.php') {
32
+		array_unshift($links, $settings_link);
33 33
 	}
34 34
 
35 35
 	return $links;
36 36
 }
37 37
 
38
-add_filter( 'plugin_action_links', 'give_plugin_action_links', 10, 2 );
38
+add_filter('plugin_action_links', 'give_plugin_action_links', 10, 2);
39 39
 
40 40
 
41 41
 /**
@@ -48,33 +48,33 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @return array $input
50 50
  */
51
-function give_plugin_row_meta( $input, $file ) {
52
-	if ( $file != 'give/give.php' ) {
51
+function give_plugin_row_meta($input, $file) {
52
+	if ($file != 'give/give.php') {
53 53
 		return $input;
54 54
 	}
55 55
 
56
-	$give_addons_link = esc_url( add_query_arg( array(
56
+	$give_addons_link = esc_url(add_query_arg(array(
57 57
 			'utm_source'   => 'plugins-page',
58 58
 			'utm_medium'   => 'plugin-row',
59 59
 			'utm_campaign' => 'admin',
60
-		), 'https://givewp.com/addons/' )
60
+		), 'https://givewp.com/addons/')
61 61
 	);
62 62
 
63
-	$give_docs_link = esc_url( add_query_arg( array(
63
+	$give_docs_link = esc_url(add_query_arg(array(
64 64
 			'utm_source'   => 'plugins-page',
65 65
 			'utm_medium'   => 'plugin-row',
66 66
 			'utm_campaign' => 'admin',
67
-		), 'https://givewp.com/documentation/' )
67
+		), 'https://givewp.com/documentation/')
68 68
 	);
69 69
 
70 70
 	$links = array(
71
-		'<a href="' . $give_docs_link . '" target="_blank">' . esc_html( 'Documentation', 'give' ) . '</a>',
72
-		'<a href="' . $give_addons_link . '" target="_blank">' . esc_html( 'Add-ons', 'give' ) . '</a>',
71
+		'<a href="'.$give_docs_link.'" target="_blank">'.esc_html('Documentation', 'give').'</a>',
72
+		'<a href="'.$give_addons_link.'" target="_blank">'.esc_html('Add-ons', 'give').'</a>',
73 73
 	);
74 74
 
75
-	$input = array_merge( $input, $links );
75
+	$input = array_merge($input, $links);
76 76
 
77 77
 	return $input;
78 78
 }
79 79
 
80
-add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
80
+add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2);
Please login to merge, or discard this patch.
includes/admin/admin-footer.php 1 patch
Spacing   +7 added lines, -7 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,15 +24,15 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return      string
26 26
  */
27
-function give_admin_rate_us( $footer_text ) {
27
+function give_admin_rate_us($footer_text) {
28 28
 	global $typenow;
29 29
 
30
-	if ( $typenow == 'give_forms' ) {
30
+	if ($typenow == 'give_forms') {
31 31
 		$rate_text = sprintf(
32 32
 			/* translators: 1: plugin name - "Give". 2: Link to 5 star rating */
33
-			esc_html( 'If you like %1$s please leave us a %2$s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ),
34
-			sprintf( '<strong>%s</strong>', esc_html( 'Give', 'give' ) ),
35
-			'<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="' . esc_attr( 'Thanks :)', 'give' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
33
+			esc_html('If you like %1$s please leave us a %2$s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'),
34
+			sprintf('<strong>%s</strong>', esc_html('Give', 'give')),
35
+			'<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="'.esc_attr('Thanks :)', 'give').'">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
36 36
 		);
37 37
 
38 38
 		return $rate_text;
@@ -41,4 +41,4 @@  discard block
 block discarded – undo
41 41
 	}
42 42
 }
43 43
 
44
-add_filter( 'admin_footer_text', 'give_admin_rate_us' );
44
+add_filter('admin_footer_text', 'give_admin_rate_us');
Please login to merge, or discard this patch.