Completed
Pull Request — master (#517)
by Chris
15:12
created
includes/gateways/offline-donations.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Offline Donations Gateway
4
- *
5
- * @package     Give
6
- * @subpackage  Gateways
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * Offline Donations Gateway
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Gateways
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 /**
13 13
  * Register the payment gateway
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_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,47 +40,47 @@  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' );
60
-		$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( esc_attr__( 'Please enter offline donation instructions in the %s.', 'give' ), '<a href="' . $settings_url . '">' . __( 'this form\'s settings', 'give' ) . '</a>' );
61
-		echo wpautop( stripslashes( $offline_instructions ) );
59
+		$settings_url         = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
60
+		$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(esc_attr__('Please enter offline donation instructions in the %s.', 'give'), '<a href="'.$settings_url.'">'.__('this form\'s settings', 'give').'</a>');
61
+		echo wpautop(stripslashes($offline_instructions));
62 62
 		?>
63 63
 	</fieldset>
64
-	<?php do_action( 'give_after_offline_info_fields', $form_id ); ?>
64
+	<?php do_action('give_after_offline_info_fields', $form_id); ?>
65 65
 	<?php
66 66
 	echo ob_get_clean();
67 67
 }
68 68
 
69
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
69
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
70 70
 
71 71
 
72
-function give_offline_billing_fields( $form_id ) {
72
+function give_offline_billing_fields($form_id) {
73 73
 	//Enable Default CC fields (billing info)
74
-	$post_offline_cc_fields   = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
75
-	$global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' );
74
+	$post_offline_cc_fields   = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
75
+	$global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields');
76 76
 
77 77
 
78
-	if ( $global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on' ) {
79
-		give_default_cc_address_fields( $form_id );
78
+	if ($global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on') {
79
+		give_default_cc_address_fields($form_id);
80 80
 	}
81 81
 }
82 82
 
83
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
83
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
84 84
 
85 85
 /**
86 86
  * Process the payment
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
  *
92 92
  * @return void
93 93
  */
94
-function give_offline_process_payment( $purchase_data ) {
94
+function give_offline_process_payment($purchase_data) {
95 95
 
96
-	$purchase_summary = give_get_purchase_summary( $purchase_data );
96
+	$purchase_summary = give_get_purchase_summary($purchase_data);
97 97
 
98 98
 	// setup the payment details
99 99
 	$payment_data = array(
100 100
 		'price'           => $purchase_data['price'],
101 101
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
102
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
102
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
103 103
 		'date'            => $purchase_data['date'],
104 104
 		'user_email'      => $purchase_data['user_email'],
105 105
 		'purchase_key'    => $purchase_data['purchase_key'],
@@ -111,20 +111,20 @@  discard block
 block discarded – undo
111 111
 
112 112
 
113 113
 	// record the pending payment
114
-	$payment = give_insert_payment( $payment_data );
114
+	$payment = give_insert_payment($payment_data);
115 115
 
116
-	if ( $payment ) {
117
-		give_offline_send_admin_notice( $payment );
118
-		give_offline_send_donor_instructions( $payment );
116
+	if ($payment) {
117
+		give_offline_send_admin_notice($payment);
118
+		give_offline_send_donor_instructions($payment);
119 119
 		give_send_to_success_page();
120 120
 	} else {
121 121
 		// if errors are present, send the user back to the donation form so they can be corrected
122
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
122
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
123 123
 	}
124 124
 
125 125
 }
126 126
 
127
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
127
+add_action('give_gateway_offline', 'give_offline_process_payment');
128 128
 
129 129
 
130 130
 /**
@@ -137,47 +137,47 @@  discard block
 block discarded – undo
137 137
  * @since       1.0
138 138
  * @return void
139 139
  */
140
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
140
+function give_offline_send_donor_instructions($payment_id = 0) {
141 141
 
142
-	$payment_data                      = give_get_payment_meta( $payment_id );
143
-	$post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
142
+	$payment_data                      = give_get_payment_meta($payment_id);
143
+	$post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
144 144
 
145 145
 	//Customize email content depending on whether the single form has been customized
146
-	$email_content = give_get_option( 'global_offline_donation_email' );
146
+	$email_content = give_get_option('global_offline_donation_email');
147 147
 
148
-	if ( $post_offline_customization_option === 'yes' ) {
149
-		$email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
148
+	if ($post_offline_customization_option === 'yes') {
149
+		$email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true);
150 150
 	}
151 151
 
152
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
153
-	$from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data );
152
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
153
+	$from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
154 154
 
155
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
156
-	$from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data );
155
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
156
+	$from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
157 157
 
158
-	$to_email = give_get_payment_user_email( $payment_id );
158
+	$to_email = give_get_payment_user_email($payment_id);
159 159
 
160
-	$subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) );
161
-	if ( $post_offline_customization_option === 'yes' ) {
162
-		$subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
160
+	$subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
161
+	if ($post_offline_customization_option === 'yes') {
162
+		$subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
163 163
 	}
164 164
 
165
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
166
-	$subject = give_do_email_tags( $subject, $payment_id );
165
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
166
+	$subject = give_do_email_tags($subject, $payment_id);
167 167
 
168
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
169
-	$message     = give_do_email_tags( $email_content, $payment_id );
168
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
169
+	$message     = give_do_email_tags($email_content, $payment_id);
170 170
 
171 171
 	$emails = Give()->emails;
172 172
 
173
-	$emails->__set( 'from_name', $from_name );
174
-	$emails->__set( 'from_email', $from_email );
175
-	$emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) );
173
+	$emails->__set('from_name', $from_name);
174
+	$emails->__set('from_email', $from_email);
175
+	$emails->__set('heading', __('Offline Donation Instructions', 'give'));
176 176
 
177
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
178
-	$emails->__set( 'headers', $headers );
177
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
178
+	$emails->__set('headers', $headers);
179 179
 
180
-	$emails->send( $to_email, $subject, $message, $attachments );
180
+	$emails->send($to_email, $subject, $message, $attachments);
181 181
 
182 182
 }
183 183
 
@@ -194,48 +194,48 @@  discard block
 block discarded – undo
194 194
  * @return void
195 195
  *
196 196
  */
197
-function give_offline_send_admin_notice( $payment_id = 0 ) {
197
+function give_offline_send_admin_notice($payment_id = 0) {
198 198
 
199 199
 	/* Send an email notification to the admin */
200 200
 	$admin_email = give_get_admin_notice_emails();
201
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
201
+	$user_info   = give_get_payment_meta_user_info($payment_id);
202 202
 
203
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
204
-		$user_data = get_userdata( $user_info['id'] );
203
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
204
+		$user_data = get_userdata($user_info['id']);
205 205
 		$name      = $user_data->display_name;
206
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
207
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
206
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
207
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
208 208
 	} else {
209 209
 		$name = $user_info['email'];
210 210
 	}
211 211
 
212
-	$amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) );
212
+	$amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)));
213 213
 
214
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id );
214
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id);
215 215
 
216
-	$admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n";
217
-	$admin_message .= esc_attr__( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' ';
218
-	$admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
216
+	$admin_message = esc_attr__('Dear Admin,', 'give')."\n\n";
217
+	$admin_message .= esc_attr__('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' ';
218
+	$admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
219 219
 
220 220
 
221
-	$admin_message .= '<strong>' . esc_attr__( 'Donor: ', 'give' ) . '</strong>' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
222
-	$admin_message .= '<strong>' . esc_attr__( 'Amount: ', 'give' ) . '</strong>' . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n";
221
+	$admin_message .= '<strong>'.esc_attr__('Donor: ', 'give').'</strong>'.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
222
+	$admin_message .= '<strong>'.esc_attr__('Amount: ', 'give').'</strong>'.html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n";
223 223
 
224 224
 	//Order URL
225
-	$order_url = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ) . '">';
226
-	$admin_message .= sprintf( __( '%sClick Here to View and/or Update Donation Details%s', 'give' ), $order_url, ' &raquo;</a>' ) . "\n\n";
225
+	$order_url = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id).'">';
226
+	$admin_message .= sprintf(__('%sClick Here to View and/or Update Donation Details%s', 'give'), $order_url, ' &raquo;</a>')."\n\n";
227 227
 
228
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
229
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
230
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
228
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
229
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
230
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
231 231
 
232 232
 	//Send Email
233 233
 	$emails = Give()->emails;
234
-	if ( ! empty( $admin_headers ) ) {
235
-		$emails->__set( 'headers', $admin_headers );
234
+	if ( ! empty($admin_headers)) {
235
+		$emails->__set('headers', $admin_headers);
236 236
 	}
237 237
 
238
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
238
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
239 239
 
240 240
 }
241 241
 
@@ -246,15 +246,15 @@  discard block
 block discarded – undo
246 246
  * @since  1.0
247 247
  * @return array
248 248
  */
249
-function give_offline_add_settings( $settings ) {
249
+function give_offline_add_settings($settings) {
250 250
 
251 251
 	//Vars
252 252
 	$prefix = '_give_';
253 253
 
254
-	$is_gateway_active = give_is_gateway_active( 'offline' );
254
+	$is_gateway_active = give_is_gateway_active('offline');
255 255
 
256 256
 	//this gateway isn't active
257
-	if ( ! $is_gateway_active ) {
257
+	if ( ! $is_gateway_active) {
258 258
 		//return settings and bounce
259 259
 		return $settings;
260 260
 	}
@@ -263,27 +263,27 @@  discard block
 block discarded – undo
263 263
 	$check_settings = array(
264 264
 
265 265
 		array(
266
-			'name'    => esc_attr__( 'Customize Offline Donations', 'give' ),
267
-			'desc'    => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ),
268
-			'id'      => $prefix . 'customize_offline_donations',
266
+			'name'    => esc_attr__('Customize Offline Donations', 'give'),
267
+			'desc'    => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'),
268
+			'id'      => $prefix.'customize_offline_donations',
269 269
 			'type'    => 'radio_inline',
270 270
 			'default' => 'no',
271 271
 			'options' => array(
272
-				'yes' => esc_attr__( 'Yes', 'give' ),
273
-				'no'  => esc_attr__( 'No', 'give' ),
272
+				'yes' => esc_attr__('Yes', 'give'),
273
+				'no'  => esc_attr__('No', 'give'),
274 274
 			),
275 275
 		),
276 276
 		array(
277
-			'name'        => esc_attr__( 'Request Billing Information', 'give' ),
278
-			'desc'        => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
279
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
277
+			'name'        => esc_attr__('Request Billing Information', 'give'),
278
+			'desc'        => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
279
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
280 280
 			'row_classes' => 'give-subfield',
281 281
 			'type'        => 'checkbox'
282 282
 		),
283 283
 		array(
284
-			'id'          => $prefix . 'offline_checkout_notes',
285
-			'name'        => esc_attr__( 'Offline Donation Instructions', 'give' ),
286
-			'desc'        => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
284
+			'id'          => $prefix.'offline_checkout_notes',
285
+			'name'        => esc_attr__('Offline Donation Instructions', 'give'),
286
+			'desc'        => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
287 287
 			'default'     => give_get_default_offline_donation_content(),
288 288
 			'type'        => 'wysiwyg',
289 289
 			'row_classes' => 'give-subfield',
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
 			)
293 293
 		),
294 294
 		array(
295
-			'id'          => $prefix . 'offline_donation_subject',
296
-			'name'        => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ),
297
-			'desc'        => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ),
298
-			'default'     => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
295
+			'id'          => $prefix.'offline_donation_subject',
296
+			'name'        => esc_attr__('Offline Donation Email Instructions Subject', 'give'),
297
+			'desc'        => esc_attr__('Enter the subject line for the donation receipt email.', 'give'),
298
+			'default'     => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
299 299
 			'row_classes' => 'give-subfield',
300 300
 			'type'        => 'text'
301 301
 		),
302 302
 		array(
303
-			'id'          => $prefix . 'offline_donation_email',
304
-			'name'        => esc_attr__( 'Offline Donation Email Instructions', 'give' ),
305
-			'desc'        => esc_attr__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
303
+			'id'          => $prefix.'offline_donation_email',
304
+			'name'        => esc_attr__('Offline Donation Email Instructions', 'give'),
305
+			'desc'        => esc_attr__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
306 306
 			'default'     => give_get_default_offline_donation_email_content(),
307 307
 			'type'        => 'wysiwyg',
308 308
 			'row_classes' => 'give-subfield',
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 		)
313 313
 	);
314 314
 
315
-	return array_merge( $settings, $check_settings );
315
+	return array_merge($settings, $check_settings);
316 316
 }
317 317
 
318
-add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' );
318
+add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings');
319 319
 
320 320
 
321 321
 /**
@@ -327,20 +327,20 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function give_get_default_offline_donation_content() {
329 329
 
330
-	$sitename = get_bloginfo( 'sitename' );
330
+	$sitename = get_bloginfo('sitename');
331 331
 
332
-	$default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
332
+	$default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
333 333
 	$default_text .= '<ol>';
334
-	$default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>';
335
-	$default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>';
336
-	$default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>';
334
+	$default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>';
335
+	$default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>';
336
+	$default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>';
337 337
 	$default_text .= '</ol>';
338
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
338
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
339 339
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
340 340
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
341
-	$default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
341
+	$default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
342 342
 
343
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
343
+	return apply_filters('give_default_offline_donation_content', $default_text);
344 344
 
345 345
 }
346 346
 
@@ -353,21 +353,21 @@  discard block
 block discarded – undo
353 353
  */
354 354
 function give_get_default_offline_donation_email_content() {
355 355
 
356
-	$sitename     = get_bloginfo( 'sitename' );
357
-	$default_text = '<p>' . esc_attr__( 'Dear {name},', 'give' ) . '</p>';
358
-	$default_text .= '<p>' . esc_attr__( '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>';
356
+	$sitename     = get_bloginfo('sitename');
357
+	$default_text = '<p>'.esc_attr__('Dear {name},', 'give').'</p>';
358
+	$default_text .= '<p>'.esc_attr__('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>';
359 359
 	$default_text .= '<ol>';
360
-	$default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>';
361
-	$default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>';
362
-	$default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>';
360
+	$default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>';
361
+	$default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>';
362
+	$default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>';
363 363
 	$default_text .= '</ol>';
364
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
364
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
365 365
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>123 G Street </em><br>';
366 366
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>San Diego, CA 92101 </em><br>';
367
-	$default_text .= '<p>' . esc_attr__( '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>';
368
-	$default_text .= '<p>' . esc_attr__( 'Sincerely,', 'give' ) . '</p>';
369
-	$default_text .= '<p>' . $sitename . '</p>';
367
+	$default_text .= '<p>'.esc_attr__('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>';
368
+	$default_text .= '<p>'.esc_attr__('Sincerely,', 'give').'</p>';
369
+	$default_text .= '<p>'.$sitename.'</p>';
370 370
 
371
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
371
+	return apply_filters('give_default_offline_donation_content', $default_text);
372 372
 
373 373
 }
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -28,66 +28,66 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
32
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32
+	if ($old_status == 'publish' || $old_status == 'complete') {
33 33
 		return;
34 34
 	} // Make sure that payments are only completed once
35 35
 
36 36
 	// Make sure the payment completion is only processed when new status is complete
37
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
37
+	if ($new_status != 'publish' && $new_status != 'complete') {
38 38
 		return;
39 39
 	}
40 40
 
41
-	$payment_meta   = give_get_payment_meta( $payment_id );
42
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
43
-	$completed_date = give_get_payment_completed_date( $payment_id );
44
-	$user_info      = give_get_payment_meta_user_info( $payment_id );
45
-	$donor_id       = give_get_payment_customer_id( $payment_id );
46
-	$amount         = give_get_payment_amount( $payment_id );
41
+	$payment_meta   = give_get_payment_meta($payment_id);
42
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
43
+	$completed_date = give_get_payment_completed_date($payment_id);
44
+	$user_info      = give_get_payment_meta_user_info($payment_id);
45
+	$donor_id       = give_get_payment_customer_id($payment_id);
46
+	$amount         = give_get_payment_amount($payment_id);
47 47
 
48
-	do_action( 'give_pre_complete_purchase', $payment_id );
48
+	do_action('give_pre_complete_purchase', $payment_id);
49 49
 
50
-	$price_id = isset( $_POST['give-price-id'] ) ? (int) $_POST['give-price-id'] : false;
50
+	$price_id = isset($_POST['give-price-id']) ? (int) $_POST['give-price-id'] : false;
51 51
 
52 52
 	// Ensure these actions only run once, ever
53
-	if ( empty( $completed_date ) ) {
53
+	if (empty($completed_date)) {
54 54
 
55
-		if ( ! give_is_test_mode() || apply_filters( 'give_log_test_payment_stats', false ) ) {
55
+		if ( ! give_is_test_mode() || apply_filters('give_log_test_payment_stats', false)) {
56 56
 
57
-			give_record_sale_in_log( $payment_meta['form_id'], $payment_id, $price_id, $creation_date );
58
-			give_increase_purchase_count( $payment_meta['form_id'] );
59
-			give_increase_earnings( $payment_meta['form_id'], $amount );
57
+			give_record_sale_in_log($payment_meta['form_id'], $payment_id, $price_id, $creation_date);
58
+			give_increase_purchase_count($payment_meta['form_id']);
59
+			give_increase_earnings($payment_meta['form_id'], $amount);
60 60
 
61 61
 		}
62 62
 
63
-		do_action( 'give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta );
63
+		do_action('give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta);
64 64
 	}
65 65
 
66 66
 
67 67
 	// Clear the total earnings cache
68
-	delete_transient( 'give_earnings_total' );
68
+	delete_transient('give_earnings_total');
69 69
 	// Clear the This Month earnings (this_monththis_month is NOT a typo)
70
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
71
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
70
+	delete_transient(md5('give_earnings_this_monththis_month'));
71
+	delete_transient(md5('give_earnings_todaytoday'));
72 72
 
73 73
 
74 74
 	// Increase the donor's purchase stats
75
-	Give()->customers->increment_stats( $donor_id, $amount );
75
+	Give()->customers->increment_stats($donor_id, $amount);
76 76
 
77
-	give_increase_total_earnings( $amount );
77
+	give_increase_total_earnings($amount);
78 78
 
79 79
 	// Ensure this action only runs once ever
80
-	if ( empty( $completed_date ) ) {
80
+	if (empty($completed_date)) {
81 81
 
82 82
 		// Save the completed date
83
-		give_update_payment_meta( $payment_id, '_give_completed_date', current_time( 'mysql' ) );
83
+		give_update_payment_meta($payment_id, '_give_completed_date', current_time('mysql'));
84 84
 
85
-		do_action( 'give_complete_purchase', $payment_id );
85
+		do_action('give_complete_purchase', $payment_id);
86 86
 	}
87 87
 
88 88
 }
89 89
 
90
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
90
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
91 91
 
92 92
 
93 93
 /**
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return void
103 103
  */
104
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
104
+function give_record_status_change($payment_id, $new_status, $old_status) {
105 105
 
106 106
 	// Get the list of statuses so that status in the payment note can be translated
107 107
 	$stati      = give_get_payment_statuses();
108
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
109
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
108
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
109
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
110 110
 
111
-	$status_change = sprintf( __( 'Status changed from %s to %s', 'give' ), $old_status, $new_status );
111
+	$status_change = sprintf(__('Status changed from %s to %s', 'give'), $old_status, $new_status);
112 112
 
113
-	give_insert_payment_note( $payment_id, $status_change );
113
+	give_insert_payment_note($payment_id, $status_change);
114 114
 }
115 115
 
116
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
116
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
117 117
 
118 118
 /**
119 119
  * Reduces earnings and donation stats when a donation is refunded
@@ -126,40 +126,40 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return void
128 128
  */
129
-function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) {
129
+function give_undo_donation_on_refund($payment_id, $new_status, $old_status) {
130 130
 
131
-	if ( 'publish' != $old_status && 'revoked' != $old_status ) {
131
+	if ('publish' != $old_status && 'revoked' != $old_status) {
132 132
 		return;
133 133
 	}
134 134
 
135
-	if ( 'refunded' != $new_status ) {
135
+	if ('refunded' != $new_status) {
136 136
 		return;
137 137
 	}
138 138
 
139 139
 	// Set necessary vars
140
-	$payment_meta = give_get_payment_meta( $payment_id );
141
-	$amount       = give_get_payment_amount( $payment_id );
140
+	$payment_meta = give_get_payment_meta($payment_id);
141
+	$amount       = give_get_payment_amount($payment_id);
142 142
 
143 143
 	// Undo this purchase
144
-	give_undo_purchase( $payment_meta['form_id'], $payment_id );
144
+	give_undo_purchase($payment_meta['form_id'], $payment_id);
145 145
 
146 146
 	// Decrease total earnings
147
-	give_decrease_total_earnings( $amount );
147
+	give_decrease_total_earnings($amount);
148 148
 
149 149
 	// Decrement the stats for the donor
150
-	$donor_id = give_get_payment_customer_id( $payment_id );
150
+	$donor_id = give_get_payment_customer_id($payment_id);
151 151
 
152
-	if ( $donor_id ) {
152
+	if ($donor_id) {
153 153
 
154
-		Give()->customers->decrement_stats( $donor_id, $amount );
154
+		Give()->customers->decrement_stats($donor_id, $amount);
155 155
 
156 156
 	}
157 157
 
158 158
 	// Clear the This Month earnings (this_monththis_month is NOT a typo)
159
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
159
+	delete_transient(md5('give_earnings_this_monththis_month'));
160 160
 }
161 161
 
162
-add_action( 'give_update_payment_status', 'give_undo_donation_on_refund', 100, 3 );
162
+add_action('give_update_payment_status', 'give_undo_donation_on_refund', 100, 3);
163 163
 
164 164
 
165 165
 /**
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
  * @param $new_status the status of the payment, probably "publish"
173 173
  * @param $old_status the status of the payment prior to being marked as "complete", probably "pending"
174 174
  */
175
-function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) {
176
-	$user_info = give_get_payment_meta_user_info( $payment_id );
175
+function give_clear_user_history_cache($payment_id, $new_status, $old_status) {
176
+	$user_info = give_get_payment_meta_user_info($payment_id);
177 177
 
178
-	delete_transient( 'give_user_' . $user_info['id'] . '_purchases' );
178
+	delete_transient('give_user_'.$user_info['id'].'_purchases');
179 179
 }
180 180
 
181
-add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 );
181
+add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3);
182 182
 
183 183
 /**
184 184
  * Updates all old payments, prior to 1.2, with new
@@ -192,32 +192,32 @@  discard block
 block discarded – undo
192 192
  *
193 193
  * @return void
194 194
  */
195
-function give_update_old_payments_with_totals( $data ) {
196
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
195
+function give_update_old_payments_with_totals($data) {
196
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
197 197
 		return;
198 198
 	}
199 199
 
200
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
200
+	if (get_option('give_payment_totals_upgraded')) {
201 201
 		return;
202 202
 	}
203 203
 
204
-	$payments = give_get_payments( array(
204
+	$payments = give_get_payments(array(
205 205
 		'offset' => 0,
206
-		'number' => - 1,
206
+		'number' => -1,
207 207
 		'mode'   => 'all'
208
-	) );
208
+	));
209 209
 
210
-	if ( $payments ) {
211
-		foreach ( $payments as $payment ) {
212
-			$meta = give_get_payment_meta( $payment->ID );
213
-			give_update_payment_meta( $payment->ID, '_give_payment_total', $meta['amount'] );
210
+	if ($payments) {
211
+		foreach ($payments as $payment) {
212
+			$meta = give_get_payment_meta($payment->ID);
213
+			give_update_payment_meta($payment->ID, '_give_payment_total', $meta['amount']);
214 214
 		}
215 215
 	}
216 216
 
217
-	add_option( 'give_payment_totals_upgraded', 1 );
217
+	add_option('give_payment_totals_upgraded', 1);
218 218
 }
219 219
 
220
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
220
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
221 221
 
222 222
 /**
223 223
  * Updates week-old+ 'pending' orders to 'abandoned'
@@ -226,29 +226,29 @@  discard block
 block discarded – undo
226 226
  * @return void
227 227
  */
228 228
 function give_mark_abandoned_donations() {
229
-	$args     = array(
229
+	$args = array(
230 230
 		'status' => 'pending',
231
-		'number' => - 1,
231
+		'number' => -1,
232 232
 		'fields' => 'ids'
233 233
 	);
234 234
 
235
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
235
+	add_filter('posts_where', 'give_filter_where_older_than_week');
236 236
 
237
-	$payments = give_get_payments( $args );
237
+	$payments = give_get_payments($args);
238 238
 
239
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
239
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
240 240
 
241
-	if ( $payments ) {
242
-		foreach ( $payments as $payment ) {
243
-			$gateway = give_get_payment_gateway( $payment );
241
+	if ($payments) {
242
+		foreach ($payments as $payment) {
243
+			$gateway = give_get_payment_gateway($payment);
244 244
 			//Skip offline gateway payments
245
-			if ( $gateway == 'offline' ) {
245
+			if ($gateway == 'offline') {
246 246
 				continue;
247 247
 			}
248 248
 			//Non-offline get marked as 'abandoned'
249
-			give_update_payment_status( $payment, 'abandoned' );
249
+			give_update_payment_status($payment, 'abandoned');
250 250
 		}
251 251
 	}
252 252
 }
253 253
 
254
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
255 254
\ No newline at end of file
255
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
256 256
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_show_upgrade_notices() {
27 27
 
28
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
28
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
29 29
 		return;
30 30
 	} // Don't show notices on the upgrades page
31 31
 
32
-	$give_version = get_option( 'give_version' );
32
+	$give_version = get_option('give_version');
33 33
 
34
-	if ( ! $give_version ) {
34
+	if ( ! $give_version) {
35 35
 		// 1.0 is the first version to use this option so we must add it
36 36
 		$give_version = '1.0';
37 37
 	}
38 38
 
39
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
39
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
40 40
 
41 41
 	/*
42 42
 	 *  NOTICE:
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 
49 49
 	//v1.3.2 Upgrades
50
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
50
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
51 51
 		printf(
52
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
53
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
52
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
53
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
54 54
 		);
55 55
 	}
56 56
 
57 57
 	//v1.3.4 Upgrades //ensure the user has gone through 1.3.4
58
-	if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) {
58
+	if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) {
59 59
 		printf(
60
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
61
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
60
+			'<div class="updated"><p>'.__('Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
61
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
62 62
 		);
63 63
 	}
64 64
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 }
70 70
 
71
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
71
+add_action('admin_notices', 'give_show_upgrade_notices');
72 72
 
73 73
 /**
74 74
  * Triggers all upgrade functions
@@ -80,26 +80,26 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function give_trigger_upgrades() {
82 82
 
83
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
84
-		wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
83
+	if ( ! current_user_can('manage_give_settings')) {
84
+		wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403));
85 85
 	}
86 86
 
87
-	$give_version = get_option( 'give_version' );
87
+	$give_version = get_option('give_version');
88 88
 
89
-	if ( ! $give_version ) {
89
+	if ( ! $give_version) {
90 90
 		// 1.0 is the first version to use this option so we must add it
91 91
 		$give_version = '1.0';
92
-		add_option( 'give_version', $give_version );
92
+		add_option('give_version', $give_version);
93 93
 	}
94 94
 
95
-	update_option( 'give_version', GIVE_VERSION );
95
+	update_option('give_version', GIVE_VERSION);
96 96
 
97
-	if ( DOING_AJAX ) {
98
-		die( 'complete' );
97
+	if (DOING_AJAX) {
98
+		die('complete');
99 99
 	} // Let AJAX know that the upgrade is complete
100 100
 }
101 101
 
102
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
102
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
103 103
 
104 104
 /**
105 105
  * Check if the upgrade routine has been run for a specific action
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
  *
111 111
  * @return bool                   If the action has been added to the completed actions array
112 112
  */
113
-function give_has_upgrade_completed( $upgrade_action = '' ) {
113
+function give_has_upgrade_completed($upgrade_action = '') {
114 114
 
115
-	if ( empty( $upgrade_action ) ) {
115
+	if (empty($upgrade_action)) {
116 116
 		return false;
117 117
 	}
118 118
 
119 119
 	$completed_upgrades = give_get_completed_upgrades();
120 120
 
121
-	return in_array( $upgrade_action, $completed_upgrades );
121
+	return in_array($upgrade_action, $completed_upgrades);
122 122
 
123 123
 }
124 124
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
  *
132 132
  * @return bool                   If the function was successfully added
133 133
  */
134
-function give_set_upgrade_complete( $upgrade_action = '' ) {
134
+function give_set_upgrade_complete($upgrade_action = '') {
135 135
 
136
-	if ( empty( $upgrade_action ) ) {
136
+	if (empty($upgrade_action)) {
137 137
 		return false;
138 138
 	}
139 139
 
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	$completed_upgrades[] = $upgrade_action;
142 142
 
143 143
 	// Remove any blanks, and only show uniques
144
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
144
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
145 145
 
146
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
146
+	return update_option('give_completed_upgrades', $completed_upgrades);
147 147
 }
148 148
 
149 149
 /**
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function give_get_completed_upgrades() {
156 156
 
157
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
157
+	$completed_upgrades = get_option('give_completed_upgrades');
158 158
 
159
-	if ( false === $completed_upgrades ) {
159
+	if (false === $completed_upgrades) {
160 160
 		$completed_upgrades = array();
161 161
 	}
162 162
 
@@ -175,30 +175,30 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function give_v132_upgrade_give_payment_customer_id() {
177 177
 	global $wpdb;
178
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
179
-		wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
178
+	if ( ! current_user_can('manage_give_settings')) {
179
+		wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403));
180 180
 	}
181 181
 
182
-	ignore_user_abort( true );
182
+	ignore_user_abort(true);
183 183
 
184
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
185
-		@set_time_limit( 0 );
184
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
185
+		@set_time_limit(0);
186 186
 	}
187 187
 
188 188
 	//UPDATE DB METAKEYS
189 189
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
190
-	$query = $wpdb->query( $sql );
190
+	$query = $wpdb->query($sql);
191 191
 
192
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
193
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
194
-	delete_option( 'give_doing_upgrade' );
195
-	wp_redirect( admin_url() );
192
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
193
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
194
+	delete_option('give_doing_upgrade');
195
+	wp_redirect(admin_url());
196 196
 	exit;
197 197
 
198 198
 
199 199
 }
200 200
 
201
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
201
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
202 202
 
203 203
 /**
204 204
  * Upgrades the Offline Status
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
 	global $wpdb;
214 214
 
215
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
216
-		wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
215
+	if ( ! current_user_can('manage_give_settings')) {
216
+		wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403));
217 217
 	}
218 218
 
219
-	ignore_user_abort( true );
219
+	ignore_user_abort(true);
220 220
 
221
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
222
-		@set_time_limit( 0 );
221
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
222
+		@set_time_limit(0);
223 223
 	}
224 224
 
225 225
 	// Get abandoned offline payments
@@ -229,32 +229,32 @@  discard block
 block discarded – undo
229 229
 	$where .= "AND ( p.post_status = 'abandoned' )";
230 230
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
231 231
 
232
-	$sql            = $select . $join . $where;
233
-	$found_payments = $wpdb->get_col( $sql );
232
+	$sql            = $select.$join.$where;
233
+	$found_payments = $wpdb->get_col($sql);
234 234
 
235 235
 
236
-	foreach ( $found_payments as $payment ) {
236
+	foreach ($found_payments as $payment) {
237 237
 
238 238
 		//Only change ones marked abandoned since our release last week
239 239
 		//because the admin may have marked some abandoned themselves
240
-		$modified_time = get_post_modified_time( 'U', false, $payment );
240
+		$modified_time = get_post_modified_time('U', false, $payment);
241 241
 
242 242
 		//1450124863 =  12/10/2015 20:42:25
243
-		if ( $modified_time >= 1450124863 ) {
243
+		if ($modified_time >= 1450124863) {
244 244
 
245
-			give_update_payment_status( $payment, 'pending' );
245
+			give_update_payment_status($payment, 'pending');
246 246
 
247 247
 		}
248 248
 
249 249
 	}
250 250
 
251
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
252
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
253
-	delete_option( 'give_doing_upgrade' );
254
-	wp_redirect( admin_url() );
251
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
252
+	give_set_upgrade_complete('upgrade_give_offline_status');
253
+	delete_option('give_doing_upgrade');
254
+	wp_redirect(admin_url());
255 255
 	exit;
256 256
 
257 257
 
258 258
 }
259 259
 
260
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
260
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
Please login to merge, or discard this patch.
includes/admin/system-info.php 1 patch
Spacing   +138 added lines, -138 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
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function give_system_info_callback() {
26 26
 
27
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
27
+	if ( ! current_user_can('manage_give_settings')) {
28 28
 		return;
29 29
 	}
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo give_tools_sysinfo_get(); ?></textarea>
33 33
 	<p class="submit">
34 34
 		<input type="hidden" name="give-action" value="download_sysinfo" />
35
-		<?php submit_button( 'Download System Info File', 'secondary', 'give-download-sysinfo', false ); ?>
35
+		<?php submit_button('Download System Info File', 'secondary', 'give-download-sysinfo', false); ?>
36 36
 	</p>
37 37
 	<style>
38 38
 		.give_forms_page_give-settings .give-submit-wrap {
@@ -55,63 +55,63 @@  discard block
 block discarded – undo
55 55
 function give_tools_sysinfo_get() {
56 56
 	global $wpdb, $give_options;
57 57
 
58
-	if ( ! class_exists( 'Browser' ) ) {
59
-		require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php';
58
+	if ( ! class_exists('Browser')) {
59
+		require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php';
60 60
 	}
61 61
 
62 62
 	$browser = new Browser();
63 63
 
64 64
 	// Get theme info
65
-	if ( get_bloginfo( 'version' ) < '3.4' ) {
66
-		$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
67
-		$theme      = $theme_data['Name'] . ' ' . $theme_data['Version'];
65
+	if (get_bloginfo('version') < '3.4') {
66
+		$theme_data = get_theme_data(get_stylesheet_directory().'/style.css');
67
+		$theme      = $theme_data['Name'].' '.$theme_data['Version'];
68 68
 	} else {
69 69
 		$theme_data = wp_get_theme();
70
-		$theme      = $theme_data->Name . ' ' . $theme_data->Version;
70
+		$theme      = $theme_data->Name.' '.$theme_data->Version;
71 71
 	}
72 72
 
73 73
 	// Try to identify the hosting provider
74 74
 	$host = give_get_host();
75 75
 
76
-	$return = '### Begin System Info ###' . "\n\n";
76
+	$return = '### Begin System Info ###'."\n\n";
77 77
 
78 78
 	// Start with the basics...
79
-	$return .= '-- Site Info' . "\n\n";
80
-	$return .= 'Site URL:                 ' . site_url() . "\n";
81
-	$return .= 'Home URL:                 ' . home_url() . "\n";
82
-	$return .= 'Multisite:                ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
79
+	$return .= '-- Site Info'."\n\n";
80
+	$return .= 'Site URL:                 '.site_url()."\n";
81
+	$return .= 'Home URL:                 '.home_url()."\n";
82
+	$return .= 'Multisite:                '.(is_multisite() ? 'Yes' : 'No')."\n";
83 83
 
84
-	$return = apply_filters( 'give_sysinfo_after_site_info', $return );
84
+	$return = apply_filters('give_sysinfo_after_site_info', $return);
85 85
 
86 86
 	// Can we determine the site's host?
87
-	if ( $host ) {
88
-		$return .= "\n" . '-- Hosting Provider' . "\n\n";
89
-		$return .= 'Host:                     ' . $host . "\n";
87
+	if ($host) {
88
+		$return .= "\n".'-- Hosting Provider'."\n\n";
89
+		$return .= 'Host:                     '.$host."\n";
90 90
 
91
-		$return = apply_filters( 'give_sysinfo_after_host_info', $return );
91
+		$return = apply_filters('give_sysinfo_after_host_info', $return);
92 92
 	}
93 93
 
94 94
 	// The local users' browser information, handled by the Browser class
95
-	$return .= "\n" . '-- User Browser' . "\n\n";
95
+	$return .= "\n".'-- User Browser'."\n\n";
96 96
 	$return .= $browser;
97 97
 
98
-	$return = apply_filters( 'give_sysinfo_after_user_browser', $return );
98
+	$return = apply_filters('give_sysinfo_after_user_browser', $return);
99 99
 
100 100
 	// WordPress configuration
101
-	$return .= "\n" . '-- WordPress Configuration' . "\n\n";
102
-	$return .= 'Version:                  ' . get_bloginfo( 'version' ) . "\n";
103
-	$return .= 'Language:                 ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
104
-	$return .= 'Permalink Structure:      ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
105
-	$return .= 'Active Theme:             ' . $theme . "\n";
106
-	$return .= 'Show On Front:            ' . get_option( 'show_on_front' ) . "\n";
101
+	$return .= "\n".'-- WordPress Configuration'."\n\n";
102
+	$return .= 'Version:                  '.get_bloginfo('version')."\n";
103
+	$return .= 'Language:                 '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n";
104
+	$return .= 'Permalink Structure:      '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n";
105
+	$return .= 'Active Theme:             '.$theme."\n";
106
+	$return .= 'Show On Front:            '.get_option('show_on_front')."\n";
107 107
 
108 108
 	// Only show page specs if frontpage is set to 'page'
109
-	if ( get_option( 'show_on_front' ) == 'page' ) {
110
-		$front_page_id = get_option( 'page_on_front' );
111
-		$blog_page_id  = get_option( 'page_for_posts' );
109
+	if (get_option('show_on_front') == 'page') {
110
+		$front_page_id = get_option('page_on_front');
111
+		$blog_page_id  = get_option('page_for_posts');
112 112
 
113
-		$return .= 'Page On Front:            ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
114
-		$return .= 'Page For Posts:           ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
113
+		$return .= 'Page On Front:            '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n";
114
+		$return .= 'Page For Posts:           '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n";
115 115
 	}
116 116
 
117 117
 	// Make sure wp_remote_post() is working
@@ -120,200 +120,200 @@  discard block
 block discarded – undo
120 120
 	$params = array(
121 121
 		'sslverify'  => false,
122 122
 		'timeout'    => 60,
123
-		'user-agent' => 'Give/' . GIVE_VERSION,
123
+		'user-agent' => 'Give/'.GIVE_VERSION,
124 124
 		'body'       => $request
125 125
 	);
126 126
 
127
-	$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
127
+	$response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
128 128
 
129
-	if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
129
+	if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
130 130
 		$WP_REMOTE_POST = 'wp_remote_post() works';
131 131
 	} else {
132 132
 		$WP_REMOTE_POST = 'wp_remote_post() does not work';
133 133
 	}
134 134
 
135
-	$return .= 'Remote Post:              ' . $WP_REMOTE_POST . "\n";
136
-	$return .= 'Table Prefix:             ' . 'Length: ' . strlen( $wpdb->prefix ) . '   Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
137
-	$return .= 'Admin AJAX:               ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n";
138
-	$return .= 'WP_DEBUG:                 ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
139
-	$return .= 'Memory Limit:             ' . WP_MEMORY_LIMIT . "\n";
140
-	$return .= 'Registered Post Stati:    ' . implode( ', ', get_post_stati() ) . "\n";
135
+	$return .= 'Remote Post:              '.$WP_REMOTE_POST."\n";
136
+	$return .= 'Table Prefix:             '.'Length: '.strlen($wpdb->prefix).'   Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n";
137
+	$return .= 'Admin AJAX:               '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n";
138
+	$return .= 'WP_DEBUG:                 '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n";
139
+	$return .= 'Memory Limit:             '.WP_MEMORY_LIMIT."\n";
140
+	$return .= 'Registered Post Stati:    '.implode(', ', get_post_stati())."\n";
141 141
 
142
-	$return = apply_filters( 'give_sysinfo_after_wordpress_config', $return );
142
+	$return = apply_filters('give_sysinfo_after_wordpress_config', $return);
143 143
 
144 144
 	// GIVE configuration
145
-	$return .= "\n" . '-- Give Configuration' . "\n\n";
146
-	$return .= 'Version:                  ' . GIVE_VERSION . "\n";
147
-	$return .= 'Upgraded From:            ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n";
148
-	$return .= 'Test Mode:                ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" );
149
-	$return .= 'Currency Code:            ' . give_get_currency() . "\n";
150
-	$return .= 'Currency Position:        ' . give_get_option( 'currency_position', 'before' ) . "\n";
151
-	$return .= 'Decimal Separator:        ' . give_get_option( 'decimal_separator', '.' ) . "\n";
152
-	$return .= 'Thousands Separator:      ' . give_get_option( 'thousands_separator', ',' ) . "\n";
145
+	$return .= "\n".'-- Give Configuration'."\n\n";
146
+	$return .= 'Version:                  '.GIVE_VERSION."\n";
147
+	$return .= 'Upgraded From:            '.get_option('give_version_upgraded_from', 'None')."\n";
148
+	$return .= 'Test Mode:                '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n");
149
+	$return .= 'Currency Code:            '.give_get_currency()."\n";
150
+	$return .= 'Currency Position:        '.give_get_option('currency_position', 'before')."\n";
151
+	$return .= 'Decimal Separator:        '.give_get_option('decimal_separator', '.')."\n";
152
+	$return .= 'Thousands Separator:      '.give_get_option('thousands_separator', ',')."\n";
153 153
 
154
-	$return = apply_filters( 'give_sysinfo_after_give_config', $return );
154
+	$return = apply_filters('give_sysinfo_after_give_config', $return);
155 155
 
156 156
 	// GIVE pages
157
-	$return .= "\n" . '-- Give Page Configuration' . "\n\n";
158
-	$return .= 'Success Page:             ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" );
159
-	$return .= 'Failure Page:             ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" );
160
-	$return .= 'Give Forms Slug:           ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" );
157
+	$return .= "\n".'-- Give Page Configuration'."\n\n";
158
+	$return .= 'Success Page:             '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n");
159
+	$return .= 'Failure Page:             '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n");
160
+	$return .= 'Give Forms Slug:           '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n");
161 161
 
162
-	$return = apply_filters( 'give_sysinfo_after_give_pages', $return );
162
+	$return = apply_filters('give_sysinfo_after_give_pages', $return);
163 163
 
164 164
 	// GIVE gateways
165
-	$return .= "\n" . '-- Give Gateway Configuration' . "\n\n";
165
+	$return .= "\n".'-- Give Gateway Configuration'."\n\n";
166 166
 
167 167
 	$active_gateways = give_get_enabled_payment_gateways();
168
-	if ( $active_gateways ) {
169
-		$default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) );
170
-		if ( $default_gateway_is_active ) {
171
-			$default_gateway = give_get_default_gateway( null );
172
-			$default_gateway = $active_gateways[ $default_gateway ]['admin_label'];
168
+	if ($active_gateways) {
169
+		$default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null));
170
+		if ($default_gateway_is_active) {
171
+			$default_gateway = give_get_default_gateway(null);
172
+			$default_gateway = $active_gateways[$default_gateway]['admin_label'];
173 173
 		} else {
174 174
 			$default_gateway = 'Test Payment';
175 175
 		}
176 176
 
177 177
 		$gateways = array();
178
-		foreach ( $active_gateways as $gateway ) {
178
+		foreach ($active_gateways as $gateway) {
179 179
 			$gateways[] = $gateway['admin_label'];
180 180
 		}
181 181
 
182
-		$return .= 'Enabled Gateways:         ' . implode( ', ', $gateways ) . "\n";
183
-		$return .= 'Default Gateway:          ' . $default_gateway . "\n";
182
+		$return .= 'Enabled Gateways:         '.implode(', ', $gateways)."\n";
183
+		$return .= 'Default Gateway:          '.$default_gateway."\n";
184 184
 	} else {
185
-		$return .= 'Enabled Gateways:         None' . "\n";
185
+		$return .= 'Enabled Gateways:         None'."\n";
186 186
 	}
187 187
 
188
-	$return = apply_filters( 'give_sysinfo_after_give_gateways', $return );
188
+	$return = apply_filters('give_sysinfo_after_give_gateways', $return);
189 189
 
190 190
 	// GIVE Templates
191
-	$dir = get_stylesheet_directory() . '/give_templates/*';
192
-	if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) {
193
-		$return .= "\n" . '-- Give Template Overrides' . "\n\n";
191
+	$dir = get_stylesheet_directory().'/give_templates/*';
192
+	if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) {
193
+		$return .= "\n".'-- Give Template Overrides'."\n\n";
194 194
 
195
-		foreach ( glob( $dir ) as $file ) {
196
-			$return .= 'Filename:                 ' . basename( $file ) . "\n";
195
+		foreach (glob($dir) as $file) {
196
+			$return .= 'Filename:                 '.basename($file)."\n";
197 197
 		}
198 198
 
199
-		$return = apply_filters( 'give_sysinfo_after_give_templates', $return );
199
+		$return = apply_filters('give_sysinfo_after_give_templates', $return);
200 200
 	}
201 201
 
202 202
 	// Must-use plugins
203 203
 	$muplugins = get_mu_plugins();
204
-	if ( count( $muplugins > 0 ) ) {
205
-		$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
204
+	if (count($muplugins > 0)) {
205
+		$return .= "\n".'-- Must-Use Plugins'."\n\n";
206 206
 
207
-		foreach ( $muplugins as $plugin => $plugin_data ) {
208
-			$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
207
+		foreach ($muplugins as $plugin => $plugin_data) {
208
+			$return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n";
209 209
 		}
210 210
 
211
-		$return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return );
211
+		$return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return);
212 212
 	}
213 213
 
214 214
 	// WordPress active plugins
215
-	$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
215
+	$return .= "\n".'-- WordPress Active Plugins'."\n\n";
216 216
 
217 217
 	$plugins        = get_plugins();
218
-	$active_plugins = get_option( 'active_plugins', array() );
218
+	$active_plugins = get_option('active_plugins', array());
219 219
 
220
-	foreach ( $plugins as $plugin_path => $plugin ) {
221
-		if ( ! in_array( $plugin_path, $active_plugins ) ) {
220
+	foreach ($plugins as $plugin_path => $plugin) {
221
+		if ( ! in_array($plugin_path, $active_plugins)) {
222 222
 			continue;
223 223
 		}
224 224
 
225
-		$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
225
+		$return .= $plugin['Name'].': '.$plugin['Version']."\n";
226 226
 	}
227 227
 
228
-	$return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return );
228
+	$return = apply_filters('give_sysinfo_after_wordpress_plugins', $return);
229 229
 
230 230
 	// WordPress inactive plugins
231
-	$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
231
+	$return .= "\n".'-- WordPress Inactive Plugins'."\n\n";
232 232
 
233
-	foreach ( $plugins as $plugin_path => $plugin ) {
234
-		if ( in_array( $plugin_path, $active_plugins ) ) {
233
+	foreach ($plugins as $plugin_path => $plugin) {
234
+		if (in_array($plugin_path, $active_plugins)) {
235 235
 			continue;
236 236
 		}
237 237
 
238
-		$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
238
+		$return .= $plugin['Name'].': '.$plugin['Version']."\n";
239 239
 	}
240 240
 
241
-	$return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return );
241
+	$return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return);
242 242
 
243
-	if ( is_multisite() ) {
243
+	if (is_multisite()) {
244 244
 		// WordPress Multisite active plugins
245
-		$return .= "\n" . '-- Network Active Plugins' . "\n\n";
245
+		$return .= "\n".'-- Network Active Plugins'."\n\n";
246 246
 
247 247
 		$plugins        = wp_get_active_network_plugins();
248
-		$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
248
+		$active_plugins = get_site_option('active_sitewide_plugins', array());
249 249
 
250
-		foreach ( $plugins as $plugin_path ) {
251
-			$plugin_base = plugin_basename( $plugin_path );
250
+		foreach ($plugins as $plugin_path) {
251
+			$plugin_base = plugin_basename($plugin_path);
252 252
 
253
-			if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
253
+			if ( ! array_key_exists($plugin_base, $active_plugins)) {
254 254
 				continue;
255 255
 			}
256 256
 
257
-			$plugin = get_plugin_data( $plugin_path );
258
-			$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
257
+			$plugin = get_plugin_data($plugin_path);
258
+			$return .= $plugin['Name'].': '.$plugin['Version']."\n";
259 259
 		}
260 260
 
261
-		$return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return );
261
+		$return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return);
262 262
 	}
263 263
 
264 264
 	// Server configuration (really just versioning)
265
-	$return .= "\n" . '-- Webserver Configuration' . "\n\n";
266
-	$return .= 'PHP Version:              ' . PHP_VERSION . "\n";
267
-	$return .= 'MySQL Version:            ' . $wpdb->db_version() . "\n";
268
-	$return .= 'Webserver Info:           ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
265
+	$return .= "\n".'-- Webserver Configuration'."\n\n";
266
+	$return .= 'PHP Version:              '.PHP_VERSION."\n";
267
+	$return .= 'MySQL Version:            '.$wpdb->db_version()."\n";
268
+	$return .= 'Webserver Info:           '.$_SERVER['SERVER_SOFTWARE']."\n";
269 269
 
270
-	$return = apply_filters( 'give_sysinfo_after_webserver_config', $return );
270
+	$return = apply_filters('give_sysinfo_after_webserver_config', $return);
271 271
 
272 272
 	// PHP configs... now we're getting to the important stuff
273
-	$return .= "\n" . '-- PHP Configuration' . "\n\n";
274
-	$return .= 'Safe Mode:                ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
275
-	$return .= 'Memory Limit:             ' . ini_get( 'memory_limit' ) . "\n";
276
-	$return .= 'Upload Max Size:          ' . ini_get( 'upload_max_filesize' ) . "\n";
277
-	$return .= 'Post Max Size:            ' . ini_get( 'post_max_size' ) . "\n";
278
-	$return .= 'Upload Max Filesize:      ' . ini_get( 'upload_max_filesize' ) . "\n";
279
-	$return .= 'Time Limit:               ' . ini_get( 'max_execution_time' ) . "\n";
280
-	$return .= 'Max Input Vars:           ' . ini_get( 'max_input_vars' ) . "\n";
281
-	$return .= 'Display Errors:           ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
282
-
283
-	$return = apply_filters( 'give_sysinfo_after_php_config', $return );
273
+	$return .= "\n".'-- PHP Configuration'."\n\n";
274
+	$return .= 'Safe Mode:                '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n");
275
+	$return .= 'Memory Limit:             '.ini_get('memory_limit')."\n";
276
+	$return .= 'Upload Max Size:          '.ini_get('upload_max_filesize')."\n";
277
+	$return .= 'Post Max Size:            '.ini_get('post_max_size')."\n";
278
+	$return .= 'Upload Max Filesize:      '.ini_get('upload_max_filesize')."\n";
279
+	$return .= 'Time Limit:               '.ini_get('max_execution_time')."\n";
280
+	$return .= 'Max Input Vars:           '.ini_get('max_input_vars')."\n";
281
+	$return .= 'Display Errors:           '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n";
282
+
283
+	$return = apply_filters('give_sysinfo_after_php_config', $return);
284 284
 
285 285
 	// PHP extensions and such
286
-	$return .= "\n" . '-- PHP Extensions' . "\n\n";
287
-	$return .= 'cURL:                     ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
286
+	$return .= "\n".'-- PHP Extensions'."\n\n";
287
+	$return .= 'cURL:                     '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n";
288 288
 
289 289
 	//cURL version
290
-	if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) {
290
+	if (function_exists('curl_init') && function_exists('curl_version')) {
291 291
 		$curl_values = curl_version();
292
-		$return .= 'cURL Version:             ' . $curl_values["version"] . "\n";
292
+		$return .= 'cURL Version:             '.$curl_values["version"]."\n";
293 293
 	}
294
-	$return .= 'fsockopen:                ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
295
-	$return .= 'SOAP Client:              ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
296
-	$return .= 'Suhosin:                  ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
294
+	$return .= 'fsockopen:                '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n";
295
+	$return .= 'SOAP Client:              '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n";
296
+	$return .= 'Suhosin:                  '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n";
297 297
 
298
-	$return = apply_filters( 'give_sysinfo_after_php_ext', $return );
298
+	$return = apply_filters('give_sysinfo_after_php_ext', $return);
299 299
 
300 300
 	// Session stuff
301
-	$return .= "\n" . '-- Session Configuration' . "\n\n";
302
-	$return .= 'Give Use Sessions:        ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n";
303
-	$return .= 'Session:                  ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
301
+	$return .= "\n".'-- Session Configuration'."\n\n";
302
+	$return .= 'Give Use Sessions:        '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n";
303
+	$return .= 'Session:                  '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n";
304 304
 
305 305
 	// The rest of this is only relevant is session is enabled
306
-	if ( isset( $_SESSION ) ) {
307
-		$return .= 'Session Name:             ' . esc_html( ini_get( 'session.name' ) ) . "\n";
308
-		$return .= 'Cookie Path:              ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
309
-		$return .= 'Save Path:                ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
310
-		$return .= 'Use Cookies:              ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
311
-		$return .= 'Use Only Cookies:         ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
306
+	if (isset($_SESSION)) {
307
+		$return .= 'Session Name:             '.esc_html(ini_get('session.name'))."\n";
308
+		$return .= 'Cookie Path:              '.esc_html(ini_get('session.cookie_path'))."\n";
309
+		$return .= 'Save Path:                '.esc_html(ini_get('session.save_path'))."\n";
310
+		$return .= 'Use Cookies:              '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n";
311
+		$return .= 'Use Only Cookies:         '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n";
312 312
 	}
313 313
 
314
-	$return = apply_filters( 'give_sysinfo_after_session_config', $return );
314
+	$return = apply_filters('give_sysinfo_after_session_config', $return);
315 315
 
316
-	$return .= "\n" . '### End System Info ###';
316
+	$return .= "\n".'### End System Info ###';
317 317
 
318 318
 	return $return;
319 319
 }
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function give_tools_sysinfo_download() {
329 329
 
330
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
330
+	if ( ! current_user_can('manage_give_settings')) {
331 331
 		return;
332 332
 	}
333 333
 
334 334
 	nocache_headers();
335 335
 
336
-	header( 'Content-Type: text/plain' );
337
-	header( 'Content-Disposition: attachment; filename="give-system-info.txt"' );
336
+	header('Content-Type: text/plain');
337
+	header('Content-Disposition: attachment; filename="give-system-info.txt"');
338 338
 
339
-	echo wp_strip_all_tags( $_POST['give-sysinfo'] );
339
+	echo wp_strip_all_tags($_POST['give-sysinfo']);
340 340
 	give_die();
341 341
 }
342 342
 
343
-add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' );
344 343
\ No newline at end of file
344
+add_action('give_download_sysinfo', 'give_tools_sysinfo_download');
345 345
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/add-ons.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 function give_add_ons_page() {
26 26
 	ob_start(); ?>
27 27
 	<div class="wrap" id="give-add-ons">
28
-		<h2><?php _e( 'Give Add-ons', 'give' ); ?>
29
-			&nbsp;&mdash;&nbsp;<a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e( 'Browse All Add-ons', 'give' ); ?>" target="_blank"><?php _e( 'View All Add-ons', 'give' ); ?>
28
+		<h2><?php _e('Give Add-ons', 'give'); ?>
29
+			&nbsp;&mdash;&nbsp;<a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e('Browse All Add-ons', 'give'); ?>" target="_blank"><?php _e('View All Add-ons', 'give'); ?>
30 30
 				<span class="dashicons dashicons-external"></span></a>
31 31
 		</h2>
32 32
 
33
-		<p><?php _e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p>
33
+		<p><?php _e('The following Add-ons extend the functionality of Give.', 'give'); ?></p>
34 34
 		<?php echo give_add_ons_get_feed(); ?>
35 35
 	</div>
36 36
 	<?php
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 function give_add_ons_get_feed() {
49 49
 
50 50
 	$addons_debug = false; //set to true to debug
51
-	$cache        = get_transient( 'give_add_ons_feed' );
51
+	$cache        = get_transient('give_add_ons_feed');
52 52
 
53
-	if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) {
54
-		$feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) );
53
+	if ($cache === false || $addons_debug === true && WP_DEBUG === true) {
54
+		$feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false));
55 55
 
56
-		if ( ! is_wp_error( $feed ) ) {
57
-			if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) {
58
-				$cache = wp_remote_retrieve_body( $feed );
59
-				set_transient( 'give_add_ons_feed', $cache, 3600 );
56
+		if ( ! is_wp_error($feed)) {
57
+			if (isset($feed['body']) && strlen($feed['body']) > 0) {
58
+				$cache = wp_remote_retrieve_body($feed);
59
+				set_transient('give_add_ons_feed', $cache, 3600);
60 60
 			}
61 61
 		} else {
62
-			$cache = '<div class="error"><p>' . __( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>';
62
+			$cache = '<div class="error"><p>'.__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>';
63 63
 		}
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
includes/gateways/paypal-standard.php 1 patch
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.0
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @access private
22 22
  * @since  1.0
23 23
  */
24
-add_action( 'give_paypal_cc_form', '__return_false' );
24
+add_action('give_paypal_cc_form', '__return_false');
25 25
 
26 26
 /**
27 27
  * Process PayPal Purchase
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_process_paypal_purchase( $purchase_data ) {
35
+function give_process_paypal_purchase($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 
41
-	$form_id = intval( $purchase_data['post_data']['give-form-id'] );
41
+	$form_id = intval($purchase_data['post_data']['give-form-id']);
42 42
 
43 43
 	// Collect payment data
44 44
 	$payment_data = array(
@@ -55,59 +55,59 @@  discard block
 block discarded – undo
55 55
 	);
56 56
 
57 57
 	// Record the pending payment
58
-	$payment = give_insert_payment( $payment_data );
58
+	$payment = give_insert_payment($payment_data);
59 59
 
60 60
 	// Check payment
61
-	if ( ! $payment ) {
61
+	if ( ! $payment) {
62 62
 		// Record the error
63
-		give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment );
63
+		give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment);
64 64
 		// Problems? send back
65
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
65
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
66 66
 	} else {
67 67
 		// Only send to PayPal if the pending payment is created successfully
68
-		$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
68
+		$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
69 69
 
70 70
 		// Get the success url
71
-		$return_url = add_query_arg( array(
71
+		$return_url = add_query_arg(array(
72 72
 			'payment-confirmation' => 'paypal',
73 73
 			'payment-id'           => $payment
74 74
 
75
-		), get_permalink( give_get_option( 'success_page' ) ) );
75
+		), get_permalink(give_get_option('success_page')));
76 76
 
77 77
 		// Get the PayPal redirect uri
78
-		$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
78
+		$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
79 79
 
80 80
 		//Item name - pass level name if variable priced
81 81
 		$item_name = $purchase_data['post_data']['give-form-title'];
82 82
 
83 83
 		//Verify has variable prices
84
-		if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) {
84
+		if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) {
85 85
 
86
-			$item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] );
86
+			$item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']);
87 87
 
88
-			$price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] );
88
+			$price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']);
89 89
 
90 90
 			//Donation given doesn't match selected level (must be a custom amount)
91
-			if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) {
92
-				$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
91
+			if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) {
92
+				$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
93 93
 				//user custom amount text if any, fallback to default if not
94
-				$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ) );
94
+				$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'));
95 95
 
96 96
 			} //Is there any donation level text?
97
-			elseif ( ! empty( $item_price_level_text ) ) {
98
-				$item_name .= ' - ' . $item_price_level_text;
97
+			elseif ( ! empty($item_price_level_text)) {
98
+				$item_name .= ' - '.$item_price_level_text;
99 99
 			}
100 100
 
101 101
 		} //Single donation: Custom Amount
102
-		elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) {
103
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
102
+		elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) {
103
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
104 104
 			//user custom amount text if any, fallback to default if not
105
-			$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ) );
105
+			$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'));
106 106
 		}
107 107
 
108 108
 		// Setup PayPal arguments
109 109
 		$paypal_args = array(
110
-			'business'      => give_get_option( 'paypal_email', false ),
110
+			'business'      => give_get_option('paypal_email', false),
111 111
 			'email'         => $purchase_data['user_email'],
112 112
 			'invoice'       => $purchase_data['purchase_key'],
113 113
 			'amount'        => $purchase_data['price'],
@@ -118,25 +118,25 @@  discard block
 block discarded – undo
118 118
 			'shipping'      => '0',
119 119
 			'no_note'       => '1',
120 120
 			'currency_code' => give_get_currency(),
121
-			'charset'       => get_bloginfo( 'charset' ),
121
+			'charset'       => get_bloginfo('charset'),
122 122
 			'custom'        => $payment,
123 123
 			'rm'            => '2',
124 124
 			'return'        => $return_url,
125
-			'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ),
125
+			'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment),
126 126
 			'notify_url'    => $listener_url,
127 127
 			'page_style'    => give_get_paypal_page_style(),
128
-			'cbt'           => get_bloginfo( 'name' ),
128
+			'cbt'           => get_bloginfo('name'),
129 129
 			'bn'            => 'givewp_SP'
130 130
 		);
131 131
 
132
-		if ( ! empty( $purchase_data['user_info']['address'] ) ) {
132
+		if ( ! empty($purchase_data['user_info']['address'])) {
133 133
 			$paypal_args['address1'] = $purchase_data['user_info']['address']['line1'];
134 134
 			$paypal_args['address2'] = $purchase_data['user_info']['address']['line2'];
135 135
 			$paypal_args['city']     = $purchase_data['user_info']['address']['city'];
136 136
 			$paypal_args['country']  = $purchase_data['user_info']['address']['country'];
137 137
 		}
138 138
 
139
-		if ( give_get_option( 'paypal_button_type' ) === 'standard' ) {
139
+		if (give_get_option('paypal_button_type') === 'standard') {
140 140
 			$paypal_extra_args = array(
141 141
 				'cmd' => '_xclick',
142 142
 			);
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
 			);
147 147
 		}
148 148
 
149
-		$paypal_args = array_merge( $paypal_extra_args, $paypal_args );
149
+		$paypal_args = array_merge($paypal_extra_args, $paypal_args);
150 150
 
151 151
 
152
-		$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data );
152
+		$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data);
153 153
 
154 154
 		// Build query
155
-		$paypal_redirect .= http_build_query( $paypal_args );
155
+		$paypal_redirect .= http_build_query($paypal_args);
156 156
 
157 157
 		// Fix for some sites that encode the entities
158
-		$paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
158
+		$paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
159 159
 
160 160
 		// Redirect to PayPal
161
-		wp_redirect( $paypal_redirect );
161
+		wp_redirect($paypal_redirect);
162 162
 		exit;
163 163
 	}
164 164
 
165 165
 }
166 166
 
167
-add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' );
167
+add_action('give_gateway_paypal', 'give_process_paypal_purchase');
168 168
 
169 169
 /**
170 170
  * Listens for a PayPal IPN requests and then sends to the processing function
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
  */
175 175
 function give_listen_for_paypal_ipn() {
176 176
 	// Regular PayPal IPN
177
-	if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) {
178
-		do_action( 'give_verify_paypal_ipn' );
177
+	if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') {
178
+		do_action('give_verify_paypal_ipn');
179 179
 	}
180 180
 }
181 181
 
182
-add_action( 'init', 'give_listen_for_paypal_ipn' );
182
+add_action('init', 'give_listen_for_paypal_ipn');
183 183
 
184 184
 /**
185 185
  * Process PayPal IPN
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 function give_process_paypal_ipn() {
191 191
 
192 192
 	// Check the request method is POST
193
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
193
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
194 194
 		return;
195 195
 	}
196 196
 
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 	$post_data = '';
199 199
 
200 200
 	// Fallback just in case post_max_size is lower than needed
201
-	if ( ini_get( 'allow_url_fopen' ) ) {
202
-		$post_data = file_get_contents( 'php://input' );
201
+	if (ini_get('allow_url_fopen')) {
202
+		$post_data = file_get_contents('php://input');
203 203
 	} else {
204 204
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
205
-		ini_set( 'post_max_size', '12M' );
205
+		ini_set('post_max_size', '12M');
206 206
 	}
207 207
 	// Start the encoded data collection with notification command
208 208
 	$encoded_data = 'cmd=_notify-validate';
@@ -211,27 +211,27 @@  discard block
 block discarded – undo
211 211
 	$arg_separator = give_get_php_arg_separator_output();
212 212
 
213 213
 	// Verify there is a post_data
214
-	if ( $post_data || strlen( $post_data ) > 0 ) {
214
+	if ($post_data || strlen($post_data) > 0) {
215 215
 		// Append the data
216
-		$encoded_data .= $arg_separator . $post_data;
216
+		$encoded_data .= $arg_separator.$post_data;
217 217
 	} else {
218 218
 		// Check if POST is empty
219
-		if ( empty( $_POST ) ) {
219
+		if (empty($_POST)) {
220 220
 			// Nothing to do
221 221
 			return;
222 222
 		} else {
223 223
 			// Loop through each POST
224
-			foreach ( $_POST as $key => $value ) {
224
+			foreach ($_POST as $key => $value) {
225 225
 				// Encode the value and append the data
226
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
226
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
227 227
 			}
228 228
 		}
229 229
 	}
230 230
 
231 231
 	// Convert collected post data to an array
232
-	parse_str( $encoded_data, $encoded_data_array );
232
+	parse_str($encoded_data, $encoded_data_array);
233 233
 
234
-	if ( ! give_get_option( 'disable_paypal_verification' ) ) {
234
+	if ( ! give_get_option('disable_paypal_verification')) {
235 235
 
236 236
 		// Validate the IPN
237 237
 
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 		);
254 254
 
255 255
 		// Get response
256
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
256
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
257 257
 
258
-		if ( is_wp_error( $api_response ) ) {
259
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) );
258
+		if (is_wp_error($api_response)) {
259
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response)));
260 260
 
261 261
 			return; // Something went wrong
262 262
 		}
263 263
 
264
-		if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) {
265
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) );
264
+		if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) {
265
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response)));
266 266
 
267 267
 			return; // Response not okay
268 268
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	}
271 271
 
272 272
 	// Check if $post_data_array has been populated
273
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
273
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
274 274
 		return;
275 275
 	}
276 276
 
@@ -279,21 +279,21 @@  discard block
 block discarded – undo
279 279
 		'payment_status' => ''
280 280
 	);
281 281
 
282
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
282
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
283 283
 
284
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
284
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
285 285
 
286
-	if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) {
286
+	if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) {
287 287
 		// Allow PayPal IPN types to be processed separately
288
-		do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id );
288
+		do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id);
289 289
 	} else {
290 290
 		// Fallback to web accept just in case the txn_type isn't present
291
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
291
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
292 292
 	}
293 293
 	exit;
294 294
 }
295 295
 
296
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
296
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
297 297
 
298 298
 /**
299 299
  * Process web accept (one time) payment IPNs
@@ -304,185 +304,185 @@  discard block
 block discarded – undo
304 304
  *
305 305
  * @return void
306 306
  */
307
-function give_process_paypal_web_accept_and_cart( $data, $payment_id ) {
307
+function give_process_paypal_web_accept_and_cart($data, $payment_id) {
308 308
 
309
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
309
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
310 310
 		return;
311 311
 	}
312 312
 
313
-	if ( empty( $payment_id ) ) {
313
+	if (empty($payment_id)) {
314 314
 		return;
315 315
 	}
316 316
 
317 317
 	// Collect payment details
318
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
318
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
319 319
 	$paypal_amount  = $data['mc_gross'];
320
-	$payment_status = strtolower( $data['payment_status'] );
321
-	$currency_code  = strtolower( $data['mc_currency'] );
322
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
323
-	$payment_meta   = give_get_payment_meta( $payment_id );
320
+	$payment_status = strtolower($data['payment_status']);
321
+	$currency_code  = strtolower($data['mc_currency']);
322
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
323
+	$payment_meta   = give_get_payment_meta($payment_id);
324 324
 
325 325
 
326
-	if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) {
326
+	if (give_get_payment_gateway($payment_id) != 'paypal') {
327 327
 		return; // this isn't a PayPal standard IPN
328 328
 	}
329 329
 
330 330
 	// Verify payment recipient
331
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) {
331
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) {
332 332
 
333
-		give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
334
-		give_update_payment_status( $payment_id, 'failed' );
335
-		give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) );
333
+		give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id);
334
+		give_update_payment_status($payment_id, 'failed');
335
+		give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give'));
336 336
 
337 337
 		return;
338 338
 	}
339 339
 
340 340
 	// Verify payment currency
341
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
341
+	if ($currency_code != strtolower($payment_meta['currency'])) {
342 342
 
343
-		give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
344
-		give_update_payment_status( $payment_id, 'failed' );
345
-		give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
343
+		give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id);
344
+		give_update_payment_status($payment_id, 'failed');
345
+		give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give'));
346 346
 
347 347
 		return;
348 348
 	}
349 349
 
350
-	if ( ! give_get_payment_user_email( $payment_id ) ) {
350
+	if ( ! give_get_payment_user_email($payment_id)) {
351 351
 
352 352
 		// No email associated with purchase, so store from PayPal
353
-		give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] );
353
+		give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']);
354 354
 
355 355
 		// Setup and store the donors's details
356 356
 		$address            = array();
357
-		$address['line1']   = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false;
358
-		$address['city']    = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false;
359
-		$address['state']   = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false;
360
-		$address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
361
-		$address['zip']     = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false;
357
+		$address['line1']   = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
358
+		$address['city']    = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
359
+		$address['state']   = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
360
+		$address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
361
+		$address['zip']     = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
362 362
 
363 363
 		$user_info = array(
364 364
 			'id'         => '-1',
365
-			'email'      => sanitize_text_field( $data['payer_email'] ),
366
-			'first_name' => sanitize_text_field( $data['first_name'] ),
367
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
365
+			'email'      => sanitize_text_field($data['payer_email']),
366
+			'first_name' => sanitize_text_field($data['first_name']),
367
+			'last_name'  => sanitize_text_field($data['last_name']),
368 368
 			'discount'   => '',
369 369
 			'address'    => $address
370 370
 		);
371 371
 
372 372
 		$payment_meta['user_info'] = $user_info;
373
-		give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta );
373
+		give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta);
374 374
 	}
375 375
 
376
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
376
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
377 377
 
378 378
 		// Process a refund
379
-		give_process_paypal_refund( $data, $payment_id );
379
+		give_process_paypal_refund($data, $payment_id);
380 380
 
381 381
 	} else {
382 382
 
383
-		if ( get_post_status( $payment_id ) == 'publish' ) {
383
+		if (get_post_status($payment_id) == 'publish') {
384 384
 			return; // Only complete payments once
385 385
 		}
386 386
 
387 387
 		// Retrieve the total purchase amount (before PayPal)
388
-		$payment_amount = give_get_payment_amount( $payment_id );
388
+		$payment_amount = give_get_payment_amount($payment_id);
389 389
 
390
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
390
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
391 391
 			// The prices don't match
392
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
393
-			give_update_payment_status( $payment_id, 'failed' );
394
-			give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
392
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id);
393
+			give_update_payment_status($payment_id, 'failed');
394
+			give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give'));
395 395
 
396 396
 			return;
397 397
 		}
398
-		if ( $purchase_key != give_get_payment_key( $payment_id ) ) {
398
+		if ($purchase_key != give_get_payment_key($payment_id)) {
399 399
 			// Purchase keys don't match
400
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
401
-			give_update_payment_status( $payment_id, 'failed' );
402
-			give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) );
400
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id);
401
+			give_update_payment_status($payment_id, 'failed');
402
+			give_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'give'));
403 403
 
404 404
 			return;
405 405
 		}
406 406
 
407
-		if ( $payment_status == 'completed' || give_is_test_mode() ) {
408
-			give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) );
409
-			give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
410
-			give_update_payment_status( $payment_id, 'publish' );
411
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
407
+		if ($payment_status == 'completed' || give_is_test_mode()) {
408
+			give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $data['txn_id']));
409
+			give_set_payment_transaction_id($payment_id, $data['txn_id']);
410
+			give_update_payment_status($payment_id, 'publish');
411
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
412 412
 
413 413
 			// Look for possible pending reasons, such as an echeck
414 414
 
415 415
 			$note = '';
416 416
 
417
-			switch ( strtolower( $data['pending_reason'] ) ) {
417
+			switch (strtolower($data['pending_reason'])) {
418 418
 
419 419
 				case 'echeck' :
420 420
 
421
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'give' );
421
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'give');
422 422
 
423 423
 					break;
424 424
 
425 425
 				case 'address' :
426 426
 
427
-					$note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give' );
427
+					$note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give');
428 428
 
429 429
 					break;
430 430
 
431 431
 				case 'intl' :
432 432
 
433
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'give' );
433
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'give');
434 434
 
435 435
 					break;
436 436
 
437 437
 				case 'multi-currency' :
438 438
 
439
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'give' );
439
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'give');
440 440
 
441 441
 					break;
442 442
 
443 443
 				case 'paymentreview' :
444 444
 				case 'regulatory_review' :
445 445
 
446
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give' );
446
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give');
447 447
 
448 448
 					break;
449 449
 
450 450
 				case 'unilateral' :
451 451
 
452
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
452
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'give');
453 453
 
454 454
 					break;
455 455
 
456 456
 				case 'upgrade' :
457 457
 
458
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'give' );
458
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'give');
459 459
 
460 460
 					break;
461 461
 
462 462
 				case 'verify' :
463 463
 
464
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'give' );
464
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'give');
465 465
 
466 466
 					break;
467 467
 
468 468
 				case 'other' :
469 469
 
470
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give' );
470
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give');
471 471
 
472 472
 					break;
473 473
 
474 474
 			}
475 475
 
476
-			if ( ! empty( $note ) ) {
476
+			if ( ! empty($note)) {
477 477
 
478
-				give_insert_payment_note( $payment_id, $note );
478
+				give_insert_payment_note($payment_id, $note);
479 479
 
480 480
 			}
481 481
 		}
482 482
 	}
483 483
 }
484 484
 
485
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 );
485
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2);
486 486
 
487 487
 /**
488 488
  * Process PayPal IPN Refunds
@@ -493,32 +493,32 @@  discard block
 block discarded – undo
493 493
  *
494 494
  * @return void
495 495
  */
496
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
496
+function give_process_paypal_refund($data, $payment_id = 0) {
497 497
 
498 498
 	// Collect payment details
499 499
 
500
-	if ( empty( $payment_id ) ) {
500
+	if (empty($payment_id)) {
501 501
 		return;
502 502
 	}
503 503
 
504
-	if ( get_post_status( $payment_id ) == 'refunded' ) {
504
+	if (get_post_status($payment_id) == 'refunded') {
505 505
 		return; // Only refund payments once
506 506
 	}
507 507
 
508
-	$payment_amount = give_get_payment_amount( $payment_id );
508
+	$payment_amount = give_get_payment_amount($payment_id);
509 509
 	$refund_amount  = $data['payment_gross'] * - 1;
510 510
 
511
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
511
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
512 512
 
513
-		give_insert_payment_note( $payment_id, sprintf( __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) );
513
+		give_insert_payment_note($payment_id, sprintf(__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id']));
514 514
 
515 515
 		return; // This is a partial refund
516 516
 
517 517
 	}
518 518
 
519
-	give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) );
520
-	give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) );
521
-	give_update_payment_status( $payment_id, 'refunded' );
519
+	give_insert_payment_note($payment_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'give'), $data['parent_txn_id'], $data['reason_code']));
520
+	give_insert_payment_note($payment_id, sprintf(__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id']));
521
+	give_update_payment_status($payment_id, 'refunded');
522 522
 }
523 523
 
524 524
 /**
@@ -530,24 +530,24 @@  discard block
 block discarded – undo
530 530
  *
531 531
  * @return string
532 532
  */
533
-function give_get_paypal_redirect( $ssl_check = false ) {
533
+function give_get_paypal_redirect($ssl_check = false) {
534 534
 
535
-	if ( is_ssl() || ! $ssl_check ) {
535
+	if (is_ssl() || ! $ssl_check) {
536 536
 		$protocal = 'https://';
537 537
 	} else {
538 538
 		$protocal = 'http://';
539 539
 	}
540 540
 
541 541
 	// Check the current payment mode
542
-	if ( give_is_test_mode() ) {
542
+	if (give_is_test_mode()) {
543 543
 		// Test mode
544
-		$paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr';
544
+		$paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr';
545 545
 	} else {
546 546
 		// Live mode
547
-		$paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr';
547
+		$paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr';
548 548
 	}
549 549
 
550
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
550
+	return apply_filters('give_paypal_uri', $paypal_uri);
551 551
 }
552 552
 
553 553
 /**
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
  */
559 559
 function give_get_paypal_page_style() {
560 560
 
561
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
561
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
562 562
 
563
-	return apply_filters( 'give_paypal_page_style', $page_style );
563
+	return apply_filters('give_paypal_page_style', $page_style);
564 564
 }
565 565
 
566 566
 /**
@@ -575,29 +575,29 @@  discard block
 block discarded – undo
575 575
  * @return string
576 576
  *
577 577
  */
578
-function give_paypal_success_page_content( $content ) {
578
+function give_paypal_success_page_content($content) {
579 579
 
580 580
 	global $payment;
581 581
 
582
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
582
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
583 583
 		return $content;
584 584
 	}
585 585
 
586
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
586
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
587 587
 
588
-	if ( ! $payment_id ) {
588
+	if ( ! $payment_id) {
589 589
 		$session    = give_get_purchase_session();
590
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
590
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
591 591
 	}
592 592
 
593
-	$payment = get_post( $payment_id );
593
+	$payment = get_post($payment_id);
594 594
 
595
-	if ( $payment && 'pending' == $payment->post_status ) {
595
+	if ($payment && 'pending' == $payment->post_status) {
596 596
 
597 597
 		// Payment is still pending so show processing indicator to fix the Race Condition, issue #
598 598
 		ob_start();
599 599
 
600
-		give_get_template_part( 'payment', 'processing' );
600
+		give_get_template_part('payment', 'processing');
601 601
 
602 602
 		$content = ob_get_clean();
603 603
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
 }
609 609
 
610
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
610
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
611 611
 
612 612
 /**
613 613
  * Given a Payment ID, extract the transaction ID
@@ -618,22 +618,22 @@  discard block
 block discarded – undo
618 618
  *
619 619
  * @return string                   Transaction ID
620 620
  */
621
-function give_paypal_get_payment_transaction_id( $payment_id ) {
621
+function give_paypal_get_payment_transaction_id($payment_id) {
622 622
 
623 623
 	$transaction_id = '';
624
-	$notes          = give_get_payment_notes( $payment_id );
624
+	$notes          = give_get_payment_notes($payment_id);
625 625
 
626
-	foreach ( $notes as $note ) {
627
-		if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
626
+	foreach ($notes as $note) {
627
+		if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
628 628
 			$transaction_id = $match[1];
629 629
 			continue;
630 630
 		}
631 631
 	}
632 632
 
633
-	return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id );
633
+	return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id);
634 634
 }
635 635
 
636
-add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 );
636
+add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1);
637 637
 
638 638
 /**
639 639
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -645,13 +645,13 @@  discard block
 block discarded – undo
645 645
  *
646 646
  * @return string                 A link to the PayPal transaction details
647 647
  */
648
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
648
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
649 649
 
650 650
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
651
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
651
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
652 652
 
653
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
653
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
654 654
 
655 655
 }
656 656
 
657
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
657
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
Please login to merge, or discard this patch.
includes/admin/reporting/class-gateways-reports-table.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Gateways Reports Table Class
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2016, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * Gateways Reports Table Class
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2016, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 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
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		switch ( $column_name ) {
67
+	public function column_default($item, $column_name) {
68
+		switch ($column_name) {
69 69
 			default:
70
-				return $item[ $column_name ];
70
+				return $item[$column_name];
71 71
 		}
72 72
 	}
73 73
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_columns() {
82 82
 		$columns = array(
83
-			'label'           => esc_attr__( 'Gateway', 'give' ),
84
-			'complete_sales'  => esc_attr__( 'Complete Transactions', 'give' ),
85
-			'pending_sales'   => esc_attr__( 'Pending / Failed Transactions', 'give' ),
86
-			'total_sales'     => esc_attr__( 'Total Transactions', 'give' ),
87
-			'total_donations' => esc_attr__( 'Total Donations', 'give' )
83
+			'label'           => esc_attr__('Gateway', 'give'),
84
+			'complete_sales'  => esc_attr__('Complete Transactions', 'give'),
85
+			'pending_sales'   => esc_attr__('Pending / Failed Transactions', 'give'),
86
+			'total_sales'     => esc_attr__('Total Transactions', 'give'),
87
+			'total_donations' => esc_attr__('Total Donations', 'give')
88 88
 		);
89 89
 
90 90
 		return $columns;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return int Current page number
100 100
 	 */
101 101
 	public function get_paged() {
102
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
102
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
103 103
 	}
104 104
 
105 105
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @since  1.0
111 111
 	 * @return void
112 112
 	 */
113
-	public function bulk_actions( $which = '' ) {
113
+	public function bulk_actions($which = '') {
114 114
 		// These aren't really bulk actions but this outputs the markup in the right place
115 115
 		give_report_views();
116 116
 	}
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param string $which
125 125
 	 */
126
-	protected function display_tablenav( $which ) {
126
+	protected function display_tablenav($which) {
127 127
 
128
-		if ( 'top' == $which ) {
129
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
128
+		if ('top' == $which) {
129
+			wp_nonce_field('bulk-'.$this->_args['plural']);
130 130
 		}
131 131
 		?>
132
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
132
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
133 133
 
134
-			<h3 class="alignleft reports-earnings-title"><span><?php _e( 'Payment Methods Report', 'give' ); ?></span></h3>
134
+			<h3 class="alignleft reports-earnings-title"><span><?php _e('Payment Methods Report', 'give'); ?></span></h3>
135 135
 
136 136
 			<div class="alignright tablenav-right">
137 137
 				<div class="actions bulkactions">
138
-					<?php $this->bulk_actions( $which ); ?>
138
+					<?php $this->bulk_actions($which); ?>
139 139
 				</div>
140 140
 				<?php
141
-				$this->extra_tablenav( $which );
142
-				$this->pagination( $which );
141
+				$this->extra_tablenav($which);
142
+				$this->pagination($which);
143 143
 				?>
144 144
 			</div>
145 145
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 		$gateways     = give_get_payment_gateways();
165 165
 		$stats        = new Give_Payment_Stats();
166 166
 
167
-		foreach ( $gateways as $gateway_id => $gateway ) {
167
+		foreach ($gateways as $gateway_id => $gateway) {
168 168
 
169
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
170
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
169
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
170
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
171 171
 
172 172
 			$reports_data[] = array(
173 173
 				'ID'              => $gateway_id,
174 174
 				'label'           => $gateway['admin_label'],
175
-				'complete_sales'  => give_format_amount( $complete_count, false ),
176
-				'pending_sales'   => give_format_amount( $pending_count, false ),
177
-				'total_sales'     => give_format_amount( $complete_count + $pending_count, false ),
178
-				'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) )
175
+				'complete_sales'  => give_format_amount($complete_count, false),
176
+				'pending_sales'   => give_format_amount($pending_count, false),
177
+				'total_sales'     => give_format_amount($complete_count + $pending_count, false),
178
+				'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id)))
179 179
 			);
180 180
 		}
181 181
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$columns               = $this->get_columns();
198 198
 		$hidden                = array(); // No hidden columns
199 199
 		$sortable              = $this->get_sortable_columns();
200
-		$this->_column_headers = array( $columns, $hidden, $sortable );
200
+		$this->_column_headers = array($columns, $hidden, $sortable);
201 201
 		$this->items           = $this->reports_data();
202 202
 
203 203
 	}
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +46 added lines, -46 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
 
@@ -39,46 +39,46 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return float|int
41 41
 	 */
42
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
43 43
 
44
-		$this->setup_dates( $start_date, $end_date );
44
+		$this->setup_dates($start_date, $end_date);
45 45
 
46 46
 		// Make sure start date is valid
47
-		if ( is_wp_error( $this->start_date ) ) {
47
+		if (is_wp_error($this->start_date)) {
48 48
 			return $this->start_date;
49 49
 		}
50 50
 
51 51
 		// Make sure end date is valid
52
-		if ( is_wp_error( $this->end_date ) ) {
52
+		if (is_wp_error($this->end_date)) {
53 53
 			return $this->end_date;
54 54
 		}
55 55
 
56
-		if ( empty( $form_id ) ) {
56
+		if (empty($form_id)) {
57 57
 
58 58
 			// Global sale stats
59
-			add_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
59
+			add_filter('give_count_payments_where', array($this, 'count_where'));
60 60
 
61
-			if ( is_array( $status ) ) {
61
+			if (is_array($status)) {
62 62
 				$count = 0;
63
-				foreach ( $status as $payment_status ) {
63
+				foreach ($status as $payment_status) {
64 64
 					$count += give_count_payments()->$payment_status;
65 65
 				}
66 66
 			} else {
67 67
 				$count = give_count_payments()->$status;
68 68
 			}
69 69
 
70
-			remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
70
+			remove_filter('give_count_payments_where', array($this, 'count_where'));
71 71
 
72 72
 		} else {
73 73
 
74 74
 			// Product specific stats
75 75
 			global $give_logs;
76 76
 
77
-			add_filter( 'posts_where', array( $this, 'payments_where' ) );
77
+			add_filter('posts_where', array($this, 'payments_where'));
78 78
 
79
-			$count = $give_logs->get_log_count( $form_id, 'sale' );
79
+			$count = $give_logs->get_log_count($form_id, 'sale');
80 80
 
81
-			remove_filter( 'posts_where', array( $this, 'payments_where' ) );
81
+			remove_filter('posts_where', array($this, 'payments_where'));
82 82
 
83 83
 		}
84 84
 
@@ -100,31 +100,31 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return float|int
102 102
 	 */
103
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
103
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
104 104
 
105 105
 		global $wpdb;
106 106
 
107
-		$this->setup_dates( $start_date, $end_date );
107
+		$this->setup_dates($start_date, $end_date);
108 108
 
109 109
 		// Make sure start date is valid
110
-		if ( is_wp_error( $this->start_date ) ) {
110
+		if (is_wp_error($this->start_date)) {
111 111
 			return $this->start_date;
112 112
 		}
113 113
 
114 114
 		// Make sure end date is valid
115
-		if ( is_wp_error( $this->end_date ) ) {
115
+		if (is_wp_error($this->end_date)) {
116 116
 			return $this->end_date;
117 117
 		}
118 118
 
119
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
119
+		add_filter('posts_where', array($this, 'payments_where'));
120 120
 
121
-		if ( empty( $form_id ) ) {
121
+		if (empty($form_id)) {
122 122
 
123 123
 			// Global earning stats
124 124
 			$args = array(
125 125
 				'post_type'              => 'give_payment',
126 126
 				'nopaging'               => true,
127
-				'post_status'            => array( 'publish', 'revoked' ),
127
+				'post_status'            => array('publish', 'revoked'),
128 128
 				'fields'                 => 'ids',
129 129
 				'update_post_term_cache' => false,
130 130
 				'suppress_filters'       => false,
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
 			);
137 137
 
138 138
 			//Filter by Gateway ID meta_key
139
-			if ( $gateway_id !== false ) {
139
+			if ($gateway_id !== false) {
140 140
 				$args['meta_key']   = '_give_payment_gateway';
141 141
 				$args['meta_value'] = $gateway_id;
142 142
 			}
143 143
 
144
-			$args = apply_filters( 'give_stats_earnings_args', $args );
145
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
144
+			$args = apply_filters('give_stats_earnings_args', $args);
145
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
146 146
 
147
-			$earnings = get_transient( $key );
148
-			if ( false === $earnings ) {
149
-				$sales    = get_posts( $args );
147
+			$earnings = get_transient($key);
148
+			if (false === $earnings) {
149
+				$sales    = get_posts($args);
150 150
 				$earnings = 0;
151
-				if ( $sales ) {
152
-					$sales = implode( ',', $sales );
153
-					$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
151
+				if ($sales) {
152
+					$sales = implode(',', $sales);
153
+					$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
154 154
 				}
155 155
 				// Cache the results for one hour
156
-				set_transient( $key, $earnings, HOUR_IN_SECONDS );
156
+				set_transient($key, $earnings, HOUR_IN_SECONDS);
157 157
 			}
158 158
 
159 159
 		} else {
@@ -174,34 +174,34 @@  discard block
 block discarded – undo
174 174
 				// This is not a valid query arg, but is used for cache keying
175 175
 			);
176 176
 
177
-			$args = apply_filters( 'give_stats_earnings_args', $args );
178
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
177
+			$args = apply_filters('give_stats_earnings_args', $args);
178
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
179 179
 			//Set transient for faster stats
180
-			$earnings = get_transient( $key );
180
+			$earnings = get_transient($key);
181 181
 
182
-			if ( false === $earnings ) {
182
+			if (false === $earnings) {
183 183
 
184
-				$log_ids  = $give_logs->get_connected_logs( $args, 'sale' );
184
+				$log_ids  = $give_logs->get_connected_logs($args, 'sale');
185 185
 				$earnings = 0;
186 186
 
187
-				if ( $log_ids ) {
188
-					$log_ids     = implode( ',', $log_ids );
189
-					$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" );
190
-					foreach ( $payment_ids as $payment_id ) {
191
-						$earnings += give_get_payment_amount( $payment_id );
187
+				if ($log_ids) {
188
+					$log_ids     = implode(',', $log_ids);
189
+					$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);");
190
+					foreach ($payment_ids as $payment_id) {
191
+						$earnings += give_get_payment_amount($payment_id);
192 192
 					}
193 193
 				}
194 194
 
195 195
 				// Cache the results for one hour
196
-				set_transient( $key, $earnings, 60 * 60 );
196
+				set_transient($key, $earnings, 60 * 60);
197 197
 			}
198 198
 		}
199 199
 
200 200
 		//remove our filter
201
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
201
+		remove_filter('posts_where', array($this, 'payments_where'));
202 202
 
203 203
 		//return earnings
204
-		return round( $earnings, give_currency_decimal_filter() );
204
+		return round($earnings, give_currency_decimal_filter());
205 205
 
206 206
 	}
207 207
 
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array
217 217
 	 */
218
-	public function get_best_selling( $number = 10 ) {
218
+	public function get_best_selling($number = 10) {
219 219
 
220 220
 		global $wpdb;
221 221
 
222
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
222
+		$give_forms = $wpdb->get_results($wpdb->prepare(
223 223
 			"SELECT post_id as form_id, max(meta_value) as sales
224 224
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
225 225
 				GROUP BY meta_value+0
226 226
 				DESC LIMIT %d;", $number
227
-		) );
227
+		));
228 228
 
229 229
 		return $give_forms;
230 230
 	}
Please login to merge, or discard this patch.
includes/class-give-session.php 2 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -167,10 +167,9 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 *
170
-	 * @param $key   $_SESSION key
171
-	 * @param $value $_SESSION variable
172 170
 	 *
173
-	 * @return mixed Session variable
171
+	 * @param string $key
172
+	 * @return string Session variable
174 173
 	 */
175 174
 	public function set( $key, $value ) {
176 175
 
@@ -222,13 +221,13 @@  discard block
 block discarded – undo
222 221
 	/**
223 222
 	 * Starts a new session if one hasn't started yet.
224 223
 	 *
225
-	 * @return null
224
+	 * @return boolean
226 225
 	 * Checks to see if the server supports PHP sessions
227 226
 	 * or if the GIVE_USE_PHP_SESSIONS constant is defined
228 227
 	 *
229 228
 	 * @access public
230 229
 	 * @since  1.0
231
-	 * @return bool $ret True if we are using PHP sessions, false otherwise
230
+	 * @return boolean $ret True if we are using PHP sessions, false otherwise
232 231
 	 */
233 232
 	public function use_php_sessions() {
234 233
 
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 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
 
@@ -71,49 +71,49 @@  discard block
 block discarded – undo
71 71
 	public function __construct() {
72 72
 
73 73
 		//Frontend only
74
-		if ( is_admin() ) {
74
+		if (is_admin()) {
75 75
 			return false;
76 76
 		}
77 77
 
78 78
 		$this->use_php_sessions = $this->use_php_sessions();
79
-		$this->exp_option       = give_get_option( 'session_lifetime' );
79
+		$this->exp_option       = give_get_option('session_lifetime');
80 80
 
81
-		if ( $this->use_php_sessions ) {
81
+		if ($this->use_php_sessions) {
82 82
 
83
-			if ( is_multisite() ) {
83
+			if (is_multisite()) {
84 84
 
85
-				$this->prefix = '_' . get_current_blog_id();
85
+				$this->prefix = '_'.get_current_blog_id();
86 86
 
87 87
 			}
88 88
 
89 89
 			// Use PHP SESSION (must be enabled via the GIVE_USE_PHP_SESSIONS constant)
90
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
90
+			add_action('init', array($this, 'maybe_start_session'), - 2);
91 91
 
92 92
 		} else {
93 93
 
94 94
 			// Use WP_Session (default)
95
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
96
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
95
+			if ( ! defined('WP_SESSION_COOKIE')) {
96
+				define('WP_SESSION_COOKIE', 'give_wp_session');
97 97
 			}
98 98
 
99
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
100
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-recursive-arrayaccess.php';
99
+			if ( ! class_exists('Recursive_ArrayAccess')) {
100
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/class-recursive-arrayaccess.php';
101 101
 			}
102 102
 
103
-			if ( ! class_exists( 'WP_Session' ) ) {
104
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-wp-session.php';
105
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/wp-session.php';
103
+			if ( ! class_exists('WP_Session')) {
104
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/class-wp-session.php';
105
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/wp-session.php';
106 106
 			}
107 107
 
108
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
109
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
108
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
109
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
110 110
 
111 111
 		}
112 112
 
113
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
114
-			add_action( 'plugins_loaded', array( $this, 'init' ), - 1 );
113
+		if (empty($this->session) && ! $this->use_php_sessions) {
114
+			add_action('plugins_loaded', array($this, 'init'), - 1);
115 115
 		} else {
116
-			add_action( 'init', array( $this, 'init' ), - 1 );
116
+			add_action('init', array($this, 'init'), - 1);
117 117
 		}
118 118
 
119 119
 	}
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function init() {
129 129
 
130
-		if ( $this->use_php_sessions ) {
131
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
130
+		if ($this->use_php_sessions) {
131
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
132 132
 		} else {
133 133
 			$this->session = WP_Session::get_instance();
134 134
 		}
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return string Session variable
162 162
 	 */
163
-	public function get( $key ) {
164
-		$key = sanitize_key( $key );
163
+	public function get($key) {
164
+		$key = sanitize_key($key);
165 165
 
166
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
166
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
167 167
 
168 168
 	}
169 169
 
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return mixed Session variable
179 179
 	 */
180
-	public function set( $key, $value ) {
180
+	public function set($key, $value) {
181 181
 
182
-		$key = sanitize_key( $key );
182
+		$key = sanitize_key($key);
183 183
 
184
-		if ( is_array( $value ) ) {
185
-			$this->session[ $key ] = serialize( $value );
184
+		if (is_array($value)) {
185
+			$this->session[$key] = serialize($value);
186 186
 		} else {
187
-			$this->session[ $key ] = $value;
187
+			$this->session[$key] = $value;
188 188
 		}
189 189
 
190
-		if ( $this->use_php_sessions ) {
191
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
190
+		if ($this->use_php_sessions) {
191
+			$_SESSION['give'.$this->prefix] = $this->session;
192 192
 		}
193 193
 
194
-		return $this->session[ $key ];
194
+		return $this->session[$key];
195 195
 	}
196 196
 
197 197
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function set_expiration_variant_time() {
208 208
 
209
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
209
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
210 210
 	}
211 211
 
212 212
 	/**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public function set_expiration_time() {
223 223
 
224
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
224
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
225 225
 	}
226 226
 
227 227
 	/**
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
 		$ret = false;
241 241
 
242 242
 		// If the database variable is already set, no need to run autodetection
243
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
243
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
244 244
 
245
-		if ( ! $give_use_php_sessions ) {
245
+		if ( ! $give_use_php_sessions) {
246 246
 
247 247
 			// Attempt to detect if the server supports PHP sessions
248
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
248
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
249 249
 
250
-				$this->set( 'give_use_php_sessions', 1 );
250
+				$this->set('give_use_php_sessions', 1);
251 251
 
252
-				if ( $this->get( 'give_use_php_sessions' ) ) {
252
+				if ($this->get('give_use_php_sessions')) {
253 253
 
254 254
 					$ret = true;
255 255
 
256 256
 					// Set the database option
257
-					update_option( 'give_use_php_sessions', true );
257
+					update_option('give_use_php_sessions', true);
258 258
 
259 259
 				}
260 260
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 		}
266 266
 
267 267
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant
268
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
268
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
269 269
 			$ret = true;
270
-		} else if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
270
+		} else if (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
271 271
 			$ret = false;
272 272
 		}
273 273
 
274
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
274
+		return (bool) apply_filters('give_use_php_sessions', $ret);
275 275
 	}
276 276
 
277 277
 	/**
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 
285 285
 		//		session_destroy(); //Uncomment for testing ONLY
286 286
 
287
-		if ( ! session_id() && ! headers_sent() ) {
288
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
287
+		if ( ! session_id() && ! headers_sent()) {
288
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
289 289
 			session_start();
290
-			setcookie( session_name(), session_id(), $lifetime ); //
291
-			setcookie( session_name() . '_expiration', $lifetime, $lifetime );
290
+			setcookie(session_name(), session_id(), $lifetime); //
291
+			setcookie(session_name().'_expiration', $lifetime, $lifetime);
292 292
 		}
293 293
 	}
294 294
 
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 
304 304
 		$expiration = false;
305 305
 
306
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
306
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
307 307
 
308
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
308
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
309 309
 
310 310
 		}
311 311
 
Please login to merge, or discard this patch.