@@ -18,17 +18,17 @@ discard block |
||
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,56 +40,56 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | ob_start(); ?> |
56 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
56 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | 58 | <?php |
59 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
59 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
60 | 60 | /* translators: %s: form settings url */ |
61 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
62 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
61 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
62 | + echo wpautop(stripslashes($offline_instructions)); |
|
63 | 63 | ?> |
64 | 64 | </fieldset> |
65 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
65 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
66 | 66 | <?php |
67 | 67 | echo ob_get_clean(); |
68 | 68 | } |
69 | 69 | |
70 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
70 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Give Offline Billing Field |
74 | 74 | * |
75 | 75 | * @param $form_id |
76 | 76 | */ |
77 | -function give_offline_billing_fields( $form_id ) { |
|
77 | +function give_offline_billing_fields($form_id) { |
|
78 | 78 | //Enable Default CC fields (billing info) |
79 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
80 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
79 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
80 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
81 | 81 | |
82 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
82 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
83 | 83 | |
84 | 84 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
85 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
86 | - give_default_cc_address_fields( $form_id ); |
|
87 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | - give_default_cc_address_fields( $form_id ); |
|
85 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
86 | + give_default_cc_address_fields($form_id); |
|
87 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | + give_default_cc_address_fields($form_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
92 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Process the payment |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | -function give_offline_process_payment( $purchase_data ) { |
|
103 | +function give_offline_process_payment($purchase_data) { |
|
104 | 104 | |
105 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
105 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
106 | 106 | |
107 | 107 | // setup the payment details |
108 | 108 | $payment_data = array( |
109 | 109 | 'price' => $purchase_data['price'], |
110 | 110 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
111 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
112 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
111 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
112 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
113 | 113 | 'date' => $purchase_data['date'], |
114 | 114 | 'user_email' => $purchase_data['user_email'], |
115 | 115 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // record the pending payment |
124 | - $payment = give_insert_payment( $payment_data ); |
|
124 | + $payment = give_insert_payment($payment_data); |
|
125 | 125 | |
126 | - if ( $payment ) { |
|
127 | - give_offline_send_admin_notice( $payment ); |
|
128 | - give_offline_send_donor_instructions( $payment ); |
|
126 | + if ($payment) { |
|
127 | + give_offline_send_admin_notice($payment); |
|
128 | + give_offline_send_donor_instructions($payment); |
|
129 | 129 | give_send_to_success_page(); |
130 | 130 | } else { |
131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -147,47 +147,47 @@ discard block |
||
147 | 147 | * @since 1.0 |
148 | 148 | * @return void |
149 | 149 | */ |
150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
151 | 151 | |
152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
153 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
152 | + $payment_data = give_get_payment_meta($payment_id); |
|
153 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
154 | 154 | |
155 | 155 | //Customize email content depending on whether the single form has been customized |
156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
157 | 157 | |
158 | - if ( $post_offline_customization_option === 'yes' ) { |
|
159 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
158 | + if ($post_offline_customization_option === 'yes') { |
|
159 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
160 | 160 | } |
161 | 161 | |
162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
163 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
163 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
166 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
167 | 167 | |
168 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
168 | + $to_email = give_get_payment_user_email($payment_id); |
|
169 | 169 | |
170 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
171 | - if ( $post_offline_customization_option === 'yes' ) { |
|
172 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
170 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
171 | + if ($post_offline_customization_option === 'yes') { |
|
172 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
176 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
176 | + $subject = give_do_email_tags($subject, $payment_id); |
|
177 | 177 | |
178 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
179 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
178 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
179 | + $message = give_do_email_tags($email_content, $payment_id); |
|
180 | 180 | |
181 | 181 | $emails = Give()->emails; |
182 | 182 | |
183 | - $emails->__set( 'from_name', $from_name ); |
|
184 | - $emails->__set( 'from_email', $from_email ); |
|
185 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
183 | + $emails->__set('from_name', $from_name); |
|
184 | + $emails->__set('from_email', $from_email); |
|
185 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
186 | 186 | |
187 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
188 | - $emails->__set( 'headers', $headers ); |
|
187 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
188 | + $emails->__set('headers', $headers); |
|
189 | 189 | |
190 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
190 | + $emails->send($to_email, $subject, $message, $attachments); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -204,52 +204,52 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * |
206 | 206 | */ |
207 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
207 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
208 | 208 | |
209 | 209 | /* Send an email notification to the admin */ |
210 | 210 | $admin_email = give_get_admin_notice_emails(); |
211 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
211 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
212 | 212 | |
213 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
214 | - $user_data = get_userdata( $user_info['id'] ); |
|
213 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
214 | + $user_data = get_userdata($user_info['id']); |
|
215 | 215 | $name = $user_data->display_name; |
216 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
217 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
216 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
217 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
218 | 218 | } else { |
219 | 219 | $name = $user_info['email']; |
220 | 220 | } |
221 | 221 | |
222 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
222 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
223 | 223 | |
224 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
224 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
225 | 225 | |
226 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
227 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' '; |
|
228 | - $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"; |
|
226 | + $admin_message = esc_attr__('Dear Admin,', 'give')."\n\n"; |
|
227 | + $admin_message .= esc_attr__('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' '; |
|
228 | + $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"; |
|
229 | 229 | |
230 | 230 | |
231 | - $admin_message .= '<strong>' . esc_attr__( 'Donor: ', 'give' ) . '</strong>' . '{fullname}' . "\n"; |
|
232 | - $admin_message .= '<strong>' . esc_attr__( 'Amount: ', 'give' ) . '</strong>' . '{price}' . "\n\n"; |
|
231 | + $admin_message .= '<strong>'.esc_attr__('Donor: ', 'give').'</strong>'.'{fullname}'."\n"; |
|
232 | + $admin_message .= '<strong>'.esc_attr__('Amount: ', 'give').'</strong>'.'{price}'."\n\n"; |
|
233 | 233 | |
234 | 234 | $admin_message .= sprintf( |
235 | 235 | '<a href="%1$s">%2$s</a>', |
236 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
237 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
238 | - ) . "\n\n"; |
|
236 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
237 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
238 | + )."\n\n"; |
|
239 | 239 | |
240 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
241 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
240 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
241 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
242 | 242 | |
243 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
244 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
243 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
244 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
245 | 245 | |
246 | 246 | //Send Email |
247 | 247 | $emails = Give()->emails; |
248 | - if ( ! empty( $admin_headers ) ) { |
|
249 | - $emails->__set( 'headers', $admin_headers ); |
|
248 | + if ( ! empty($admin_headers)) { |
|
249 | + $emails->__set('headers', $admin_headers); |
|
250 | 250 | } |
251 | 251 | |
252 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
252 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | * @since 1.0 |
261 | 261 | * @return array |
262 | 262 | */ |
263 | -function give_offline_add_settings( $settings ) { |
|
263 | +function give_offline_add_settings($settings) { |
|
264 | 264 | |
265 | 265 | //Vars |
266 | 266 | $prefix = '_give_'; |
267 | 267 | |
268 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
268 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
269 | 269 | |
270 | 270 | //this gateway isn't active |
271 | - if ( ! $is_gateway_active ) { |
|
271 | + if ( ! $is_gateway_active) { |
|
272 | 272 | //return settings and bounce |
273 | 273 | return $settings; |
274 | 274 | } |
@@ -277,27 +277,27 @@ discard block |
||
277 | 277 | $check_settings = array( |
278 | 278 | |
279 | 279 | array( |
280 | - 'name' => esc_attr__( 'Customize Offline Donations', 'give' ), |
|
281 | - 'desc' => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
282 | - 'id' => $prefix . 'customize_offline_donations', |
|
280 | + 'name' => esc_attr__('Customize Offline Donations', 'give'), |
|
281 | + 'desc' => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
282 | + 'id' => $prefix.'customize_offline_donations', |
|
283 | 283 | 'type' => 'radio_inline', |
284 | 284 | 'default' => 'no', |
285 | 285 | 'options' => array( |
286 | - 'yes' => esc_attr__( 'Yes', 'give' ), |
|
287 | - 'no' => esc_attr__( 'No', 'give' ), |
|
286 | + 'yes' => esc_attr__('Yes', 'give'), |
|
287 | + 'no' => esc_attr__('No', 'give'), |
|
288 | 288 | ), |
289 | 289 | ), |
290 | 290 | array( |
291 | - 'name' => esc_attr__( 'Request Billing Information', 'give' ), |
|
292 | - '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' ), |
|
293 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
291 | + 'name' => esc_attr__('Request Billing Information', 'give'), |
|
292 | + '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'), |
|
293 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
294 | 294 | 'row_classes' => 'give-subfield', |
295 | 295 | 'type' => 'checkbox' |
296 | 296 | ), |
297 | 297 | array( |
298 | - 'id' => $prefix . 'offline_checkout_notes', |
|
299 | - 'name' => esc_attr__( 'Offline Donation Instructions', 'give' ), |
|
300 | - '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' ), |
|
298 | + 'id' => $prefix.'offline_checkout_notes', |
|
299 | + 'name' => esc_attr__('Offline Donation Instructions', 'give'), |
|
300 | + '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'), |
|
301 | 301 | 'default' => give_get_default_offline_donation_content(), |
302 | 302 | 'type' => 'wysiwyg', |
303 | 303 | 'row_classes' => 'give-subfield', |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | ) |
307 | 307 | ), |
308 | 308 | array( |
309 | - 'id' => $prefix . 'offline_donation_subject', |
|
310 | - 'name' => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
311 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
312 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
309 | + 'id' => $prefix.'offline_donation_subject', |
|
310 | + 'name' => esc_attr__('Offline Donation Email Instructions Subject', 'give'), |
|
311 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
312 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
313 | 313 | 'row_classes' => 'give-subfield', |
314 | 314 | 'type' => 'text' |
315 | 315 | ), |
316 | 316 | array( |
317 | - 'id' => $prefix . 'offline_donation_email', |
|
318 | - 'name' => esc_attr__( 'Offline Donation Email Instructions', 'give' ), |
|
319 | - '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' ), |
|
317 | + 'id' => $prefix.'offline_donation_email', |
|
318 | + 'name' => esc_attr__('Offline Donation Email Instructions', 'give'), |
|
319 | + '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'), |
|
320 | 320 | 'default' => give_get_default_offline_donation_email_content(), |
321 | 321 | 'type' => 'wysiwyg', |
322 | 322 | 'row_classes' => 'give-subfield', |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | ) |
327 | 327 | ); |
328 | 328 | |
329 | - return array_merge( $settings, $check_settings ); |
|
329 | + return array_merge($settings, $check_settings); |
|
330 | 330 | } |
331 | 331 | |
332 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
332 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -341,32 +341,32 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_get_default_offline_donation_content() { |
343 | 343 | |
344 | - $sitename = get_bloginfo( 'sitename' ); |
|
344 | + $sitename = get_bloginfo('sitename'); |
|
345 | 345 | |
346 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
346 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
347 | 347 | $default_text .= '<ol>'; |
348 | 348 | $default_text .= '<li>'; |
349 | 349 | $default_text .= sprintf( |
350 | 350 | /* translators: %s: site name */ |
351 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
351 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
352 | 352 | $sitename |
353 | 353 | ); |
354 | 354 | $default_text .= '</li>'; |
355 | 355 | $default_text .= '<li>'; |
356 | 356 | $default_text .= sprintf( |
357 | 357 | /* translators: %s: site name */ |
358 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
358 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
359 | 359 | $sitename |
360 | 360 | ); |
361 | 361 | $default_text .= '</li>'; |
362 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
362 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
363 | 363 | $default_text .= '</ol>'; |
364 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
364 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
365 | 365 | $default_text .= ' <em>123 G Street </em><br>'; |
366 | 366 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
367 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
367 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
368 | 368 | |
369 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
369 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
@@ -379,33 +379,33 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function give_get_default_offline_donation_email_content() { |
381 | 381 | |
382 | - $sitename = get_bloginfo( 'sitename' ); |
|
383 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
384 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
382 | + $sitename = get_bloginfo('sitename'); |
|
383 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
384 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
385 | 385 | $default_text .= '<ol>'; |
386 | 386 | $default_text .= '<li>'; |
387 | 387 | $default_text .= sprintf( |
388 | 388 | /* translators: %s: site name */ |
389 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
389 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
390 | 390 | $sitename |
391 | 391 | ); |
392 | 392 | $default_text .= '</li>'; |
393 | 393 | $default_text .= '<li>'; |
394 | 394 | $default_text .= sprintf( |
395 | 395 | /* translators: %s: site name */ |
396 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
396 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
397 | 397 | $sitename |
398 | 398 | ); |
399 | 399 | $default_text .= '</li>'; |
400 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
400 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
401 | 401 | $default_text .= '</ol>'; |
402 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
402 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
403 | 403 | $default_text .= ' <em>123 G Street </em><br>'; |
404 | 404 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
405 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
406 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
407 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
405 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
406 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
407 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
408 | 408 | |
409 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
409 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
410 | 410 | |
411 | 411 | } |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // Set parent defaults. |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
50 | 50 | 'ajax' => false // Does this table support ajax?. |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Column Name |
64 | 64 | */ |
65 | - public function column_default( $item, $column_name ) { |
|
65 | + public function column_default($item, $column_name) { |
|
66 | 66 | |
67 | - switch ( $column_name ) { |
|
67 | + switch ($column_name) { |
|
68 | 68 | case 'ID' : |
69 | 69 | return $item['ID_label']; |
70 | 70 | case 'payment_id' : |
71 | - return empty( $item->payment_id ) ? esc_html__( 'n/a', 'give' ) : $item->payment_id; |
|
71 | + return empty($item->payment_id) ? esc_html__('n/a', 'give') : $item->payment_id; |
|
72 | 72 | case 'gateway' : |
73 | - return empty( $item->gateway ) ? esc_html__( 'n/a', 'give' ) : $item->gateway; |
|
73 | + return empty($item->gateway) ? esc_html__('n/a', 'give') : $item->gateway; |
|
74 | 74 | case 'error' : |
75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
76 | 76 | default: |
77 | - return $item[ $column_name ]; |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function column_message( $item ) { ?> |
|
92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
91 | + public function column_message($item) { ?> |
|
92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
94 | 94 | <?php |
95 | 95 | |
96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
97 | 97 | |
98 | - $serialized = strpos( $log_message, '{"' ); |
|
98 | + $serialized = strpos($log_message, '{"'); |
|
99 | 99 | |
100 | 100 | // Check to see if the log message contains serialized information |
101 | - if ( $serialized !== false ) { |
|
102 | - $length = strlen( $log_message ) - $serialized; |
|
103 | - $intro = substr( $log_message, 0, - $length ); |
|
104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
101 | + if ($serialized !== false) { |
|
102 | + $length = strlen($log_message) - $serialized; |
|
103 | + $intro = substr($log_message, 0, - $length); |
|
104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
105 | 105 | |
106 | - echo wpautop( $intro ); |
|
107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
106 | + echo wpautop($intro); |
|
107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
109 | 109 | } else { |
110 | 110 | // No serialized data found |
111 | - echo wpautop( $log_message ); |
|
111 | + echo wpautop($log_message); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_columns() { |
126 | 126 | $columns = array( |
127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
130 | - 'payment_id' => esc_html__( 'Payment ID', 'give' ), |
|
131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
128 | + 'error' => esc_html__('Error', 'give'), |
|
129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
130 | + 'payment_id' => esc_html__('Payment ID', 'give'), |
|
131 | + 'date' => esc_html__('Date', 'give'), |
|
132 | + 'message' => esc_html__('Details', 'give') |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return int Current page number |
144 | 144 | */ |
145 | 145 | public function get_paged() { |
146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @since 1.0 |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function bulk_actions( $which = '' ) { |
|
156 | + public function bulk_actions($which = '') { |
|
157 | 157 | give_log_views(); |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Prevent the queries from getting cached. |
173 | 173 | // Without this there are occasional memory issues for some installs. |
174 | - wp_suspend_cache_addition( true ); |
|
174 | + wp_suspend_cache_addition(true); |
|
175 | 175 | |
176 | 176 | $logs_data = array(); |
177 | 177 | $paged = $this->get_paged(); |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | 'paged' => $paged |
181 | 181 | ); |
182 | 182 | |
183 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
183 | + $logs = $give_logs->get_connected_logs($log_query); |
|
184 | 184 | |
185 | - if ( $logs ) { |
|
186 | - foreach ( $logs as $log ) { |
|
185 | + if ($logs) { |
|
186 | + foreach ($logs as $log) { |
|
187 | 187 | |
188 | 188 | $logs_data[] = array( |
189 | 189 | 'ID' => $log->ID, |
190 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
190 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
191 | 191 | 'payment_id' => $log->post_parent, |
192 | 192 | 'error' => 'error', |
193 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
193 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
194 | 194 | 'date' => $log->post_date |
195 | 195 | ); |
196 | 196 | } |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @param string $which |
214 | 214 | */ |
215 | - protected function display_tablenav( $which ) { |
|
216 | - if ( 'top' === $which ) { |
|
217 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
215 | + protected function display_tablenav($which) { |
|
216 | + if ('top' === $which) { |
|
217 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
218 | 218 | } |
219 | 219 | ?> |
220 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
220 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
221 | 221 | |
222 | 222 | <div class="alignleft actions bulkactions"> |
223 | - <?php $this->bulk_actions( $which ); ?> |
|
223 | + <?php $this->bulk_actions($which); ?> |
|
224 | 224 | </div> |
225 | 225 | <?php |
226 | - $this->extra_tablenav( $which ); |
|
227 | - $this->pagination( $which ); |
|
226 | + $this->extra_tablenav($which); |
|
227 | + $this->pagination($which); |
|
228 | 228 | ?> |
229 | 229 | |
230 | 230 | <br class="clear"/> |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | $columns = $this->get_columns(); |
252 | 252 | $hidden = array(); // No hidden columns |
253 | 253 | $sortable = $this->get_sortable_columns(); |
254 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
254 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
255 | 255 | $this->items = $this->get_logs(); |
256 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
256 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
257 | 257 | |
258 | - $this->set_pagination_args( array( |
|
258 | + $this->set_pagination_args(array( |
|
259 | 259 | 'total_items' => $total_items, |
260 | 260 | 'per_page' => $this->per_page, |
261 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
261 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
262 | 262 | ) |
263 | 263 | ); |
264 | 264 | } |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file. |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types. |
26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids', |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies. |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms. |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies. |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages. |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | Give()->roles->remove_caps(); |
73 | 73 | |
74 | 74 | // Delete the Roles. |
75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
76 | - foreach ( $give_roles as $role ) { |
|
77 | - remove_role( $role ); |
|
75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
76 | + foreach ($give_roles as $role) { |
|
77 | + remove_role($role); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Remove all database tables. |
81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
84 | 84 | |
85 | 85 | // Cleanup Cron Events. |
86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
89 | 89 | |
90 | 90 | // Get all options. |
91 | 91 | $give_option_names = $wpdb->get_results( |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ARRAY_A |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! empty( $give_option_names ) ) { |
|
99 | + if ( ! empty($give_option_names)) { |
|
100 | 100 | // Convert option name to transient or option name. |
101 | 101 | $new_give_option_names = array(); |
102 | 102 | |
103 | - foreach ( $give_option_names as $option ) { |
|
104 | - $new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) ) |
|
105 | - ? str_replace( '_transient_', '', $option['option_name'] ) |
|
103 | + foreach ($give_option_names as $option) { |
|
104 | + $new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_')) |
|
105 | + ? str_replace('_transient_', '', $option['option_name']) |
|
106 | 106 | : $option['option_name']; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $give_option_names = $new_give_option_names; |
110 | 110 | |
111 | 111 | // Delete all the Plugin Options. |
112 | - foreach ( $give_option_names as $option ) { |
|
113 | - if ( false !== strpos( $option, '_transient_' ) ) { |
|
114 | - delete_transient( $option ); |
|
112 | + foreach ($give_option_names as $option) { |
|
113 | + if (false !== strpos($option, '_transient_')) { |
|
114 | + delete_transient($option); |
|
115 | 115 | } else { |
116 | - delete_option( $option ); |
|
116 | + delete_option($option); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @return Give |
196 | 196 | */ |
197 | 197 | public static function instance() { |
198 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
198 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
199 | 199 | self::$instance = new Give; |
200 | 200 | self::$instance->setup_constants(); |
201 | 201 | |
202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
202 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
203 | 203 | |
204 | 204 | self::$instance->includes(); |
205 | 205 | self::$instance->roles = new Give_Roles(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function __clone() { |
234 | 234 | // Cloning instances of the class is forbidden |
235 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
235 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function __wakeup() { |
247 | 247 | // Unserializing instances of the class is forbidden. |
248 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
248 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -259,33 +259,33 @@ discard block |
||
259 | 259 | private function setup_constants() { |
260 | 260 | |
261 | 261 | // Plugin version |
262 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
263 | - define( 'GIVE_VERSION', '1.6.1' ); |
|
262 | + if ( ! defined('GIVE_VERSION')) { |
|
263 | + define('GIVE_VERSION', '1.6.1'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Plugin Folder Path |
267 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
267 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
268 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Plugin Folder URL |
272 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
272 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
273 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Plugin Basename aka: "give/give.php" |
277 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
277 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
278 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Plugin Root File |
282 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
282 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
283 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Make sure CAL_GREGORIAN is defined |
287 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
288 | - define( 'CAL_GREGORIAN', 1 ); |
|
287 | + if ( ! defined('CAL_GREGORIAN')) { |
|
288 | + define('CAL_GREGORIAN', 1); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -300,110 +300,110 @@ discard block |
||
300 | 300 | private function includes() { |
301 | 301 | global $give_options; |
302 | 302 | |
303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
304 | 304 | $give_options = give_get_settings(); |
305 | 305 | |
306 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
307 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
311 | - |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
313 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
314 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
326 | - |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
329 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
332 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
335 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/process-purchase.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
341 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated-functions.php'; |
|
342 | - |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
347 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
348 | - |
|
349 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
353 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
354 | - |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
359 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
360 | - |
|
361 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
362 | - |
|
363 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
365 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
366 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
367 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
368 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
369 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
370 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
371 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
373 | - |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
376 | - |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
382 | - |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
390 | - |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
400 | - |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
306 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
307 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
311 | + |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
313 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
314 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
326 | + |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
329 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
332 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
335 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/process-purchase.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
341 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated-functions.php'; |
|
342 | + |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
347 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
348 | + |
|
349 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
353 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
354 | + |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
359 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
360 | + |
|
361 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
362 | + |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
365 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
366 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
368 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
369 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
370 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
371 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
373 | + |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
376 | + |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
382 | + |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
390 | + |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
400 | + |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,26 +417,26 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function load_textdomain() { |
419 | 419 | // Set filter for Give's languages directory |
420 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
421 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
420 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
421 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
422 | 422 | |
423 | 423 | // Traditional WordPress plugin locale filter |
424 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
425 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
424 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
425 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
426 | 426 | |
427 | 427 | // Setup paths to current locale file |
428 | - $mofile_local = $give_lang_dir . $mofile; |
|
429 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
428 | + $mofile_local = $give_lang_dir.$mofile; |
|
429 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
430 | 430 | |
431 | - if ( file_exists( $mofile_global ) ) { |
|
431 | + if (file_exists($mofile_global)) { |
|
432 | 432 | // Look in global /wp-content/languages/give folder |
433 | - load_textdomain( 'give', $mofile_global ); |
|
434 | - } elseif ( file_exists( $mofile_local ) ) { |
|
433 | + load_textdomain('give', $mofile_global); |
|
434 | + } elseif (file_exists($mofile_local)) { |
|
435 | 435 | // Look in local location from filter `give_languages_directory` |
436 | - load_textdomain( 'give', $mofile_local ); |
|
436 | + load_textdomain('give', $mofile_local); |
|
437 | 437 | } else { |
438 | 438 | // Load the default language files packaged up w/ Give |
439 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
439 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * @global $wp_version |
25 | 25 | * @return void |
26 | 26 | */ |
27 | -function give_install( $network_wide = false ) { |
|
27 | +function give_install($network_wide = false) { |
|
28 | 28 | |
29 | 29 | global $wpdb; |
30 | 30 | |
31 | - if ( is_multisite() && $network_wide ) { |
|
31 | + if (is_multisite() && $network_wide) { |
|
32 | 32 | |
33 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
33 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
34 | 34 | |
35 | - switch_to_blog( $blog_id ); |
|
35 | + switch_to_blog($blog_id); |
|
36 | 36 | give_run_install(); |
37 | 37 | restore_current_blog(); |
38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | } |
48 | 48 | |
49 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
49 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Run the Give Install process. |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | give_setup_post_types(); |
63 | 63 | |
64 | 64 | // Clear the permalinks. |
65 | - flush_rewrite_rules( false ); |
|
65 | + flush_rewrite_rules(false); |
|
66 | 66 | |
67 | 67 | // Add Upgraded From Option. |
68 | - $current_version = get_option( 'give_version' ); |
|
69 | - if ( $current_version ) { |
|
70 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
68 | + $current_version = get_option('give_version'); |
|
69 | + if ($current_version) { |
|
70 | + update_option('give_version_upgraded_from', $current_version); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Setup some default options. |
74 | 74 | $options = array(); |
75 | 75 | |
76 | 76 | // Checks if the Success Page option exists AND that the page exists. |
77 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
77 | + if ( ! get_post(give_get_option('success_page'))) { |
|
78 | 78 | |
79 | 79 | // Donations Confirmation (Success) Page. |
80 | 80 | $success = wp_insert_post( |
81 | 81 | array( |
82 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
82 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
83 | 83 | 'post_content' => '[give_receipt]', |
84 | 84 | 'post_status' => 'publish', |
85 | 85 | 'post_author' => 1, |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Checks if the Failure Page option exists AND that the page exists. |
96 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
96 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
97 | 97 | |
98 | 98 | // Failed Donation Page. |
99 | 99 | $failed = wp_insert_post( |
100 | 100 | array( |
101 | - 'post_title' => esc_html__( 'Transaction Failed', 'give' ), |
|
102 | - 'post_content' => esc_html__( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ), |
|
101 | + 'post_title' => esc_html__('Transaction Failed', 'give'), |
|
102 | + 'post_content' => esc_html__('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'), |
|
103 | 103 | 'post_status' => 'publish', |
104 | 104 | 'post_author' => 1, |
105 | 105 | 'post_type' => 'page', |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | // Checks if the History Page option exists AND that the page exists. |
114 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
114 | + if ( ! get_post(give_get_option('history_page'))) { |
|
115 | 115 | // Purchase History (History) Page. |
116 | 116 | $history = wp_insert_post( |
117 | 117 | array( |
118 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
118 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
119 | 119 | 'post_content' => '[donation_history]', |
120 | 120 | 'post_status' => 'publish', |
121 | 121 | 'post_author' => 1, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
131 | - if ( empty( $current_version ) ) { |
|
131 | + if (empty($current_version)) { |
|
132 | 132 | $options['base_country'] = 'US'; |
133 | 133 | $options['test_mode'] = 1; |
134 | 134 | $options['currency'] = 'USD'; |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | // Populate the default values. |
155 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
156 | - update_option( 'give_version', GIVE_VERSION ); |
|
155 | + update_option('give_settings', array_merge($give_options, $options)); |
|
156 | + update_option('give_version', GIVE_VERSION); |
|
157 | 157 | |
158 | 158 | // Create Give roles. |
159 | 159 | $roles = new Give_Roles(); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $roles->add_caps(); |
162 | 162 | |
163 | 163 | $api = new Give_API(); |
164 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
164 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
165 | 165 | |
166 | 166 | // Create the customers databases. |
167 | 167 | @Give()->customers->create_table(); |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | Give()->session->use_php_sessions(); |
172 | 172 | |
173 | 173 | // Add a temporary option to note that Give pages have been created. |
174 | - set_transient( '_give_installed', $options, 30 ); |
|
174 | + set_transient('_give_installed', $options, 30); |
|
175 | 175 | |
176 | - if ( ! $current_version ) { |
|
176 | + if ( ! $current_version) { |
|
177 | 177 | |
178 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
178 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
179 | 179 | |
180 | 180 | // When new upgrade routines are added, mark them as complete on fresh install. |
181 | 181 | $upgrade_routines = array( |
@@ -184,22 +184,22 @@ discard block |
||
184 | 184 | 'upgrade_give_offline_status' |
185 | 185 | ); |
186 | 186 | |
187 | - foreach ( $upgrade_routines as $upgrade ) { |
|
188 | - give_set_upgrade_complete( $upgrade ); |
|
187 | + foreach ($upgrade_routines as $upgrade) { |
|
188 | + give_set_upgrade_complete($upgrade); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | // Bail if activating from network, or bulk. |
193 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
193 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Add the transient to redirect. |
198 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
198 | + set_transient('_give_activation_redirect', true, 30); |
|
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
202 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Network Activated New Site Setup. |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * @param int $site_id The Site ID. |
216 | 216 | * @param array $meta Blog Meta. |
217 | 217 | */ |
218 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
218 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
219 | 219 | |
220 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
220 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
221 | 221 | |
222 | - switch_to_blog( $blog_id ); |
|
222 | + switch_to_blog($blog_id); |
|
223 | 223 | give_install(); |
224 | 224 | restore_current_blog(); |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | } |
229 | 229 | |
230 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
230 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | /** |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array The tables to drop. |
242 | 242 | */ |
243 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
243 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
244 | 244 | |
245 | - switch_to_blog( $blog_id ); |
|
245 | + switch_to_blog($blog_id); |
|
246 | 246 | $customers_db = new Give_DB_Customers(); |
247 | 247 | $customer_meta_db = new Give_DB_Customer_Meta(); |
248 | 248 | |
249 | - if ( $customers_db->installed() ) { |
|
249 | + if ($customers_db->installed()) { |
|
250 | 250 | $tables[] = $customers_db->table_name; |
251 | 251 | $tables[] = $customer_meta_db->table_name; |
252 | 252 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
259 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Post-installation |
@@ -268,16 +268,16 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function give_after_install() { |
270 | 270 | |
271 | - if ( ! is_admin() ) { |
|
271 | + if ( ! is_admin()) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
275 | - $give_options = get_transient( '_give_installed' ); |
|
276 | - $give_table_check = get_option( '_give_table_check', false ); |
|
275 | + $give_options = get_transient('_give_installed'); |
|
276 | + $give_table_check = get_option('_give_table_check', false); |
|
277 | 277 | |
278 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
278 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
279 | 279 | |
280 | - if ( ! @Give()->customer_meta->installed() ) { |
|
280 | + if ( ! @Give()->customer_meta->installed()) { |
|
281 | 281 | |
282 | 282 | // Create the customer meta database |
283 | 283 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -285,27 +285,27 @@ discard block |
||
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | - if ( ! @Give()->customers->installed() ) { |
|
288 | + if ( ! @Give()->customers->installed()) { |
|
289 | 289 | // Create the customers database |
290 | 290 | // (this ensures it creates it on multisite instances where it is network activated). |
291 | 291 | @Give()->customers->create_table(); |
292 | 292 | |
293 | - do_action( 'give_after_install', $give_options ); |
|
293 | + do_action('give_after_install', $give_options); |
|
294 | 294 | } |
295 | 295 | |
296 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
296 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
297 | 297 | |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Delete the transient |
301 | - if ( false !== $give_options ) { |
|
302 | - delete_transient( '_give_installed' ); |
|
301 | + if (false !== $give_options) { |
|
302 | + delete_transient('_give_installed'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | -add_action( 'admin_init', 'give_after_install' ); |
|
308 | +add_action('admin_init', 'give_after_install'); |
|
309 | 309 | |
310 | 310 | |
311 | 311 | /** |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | |
321 | 321 | global $wp_roles; |
322 | 322 | |
323 | - if ( ! is_object( $wp_roles ) ) { |
|
323 | + if ( ! is_object($wp_roles)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
327 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
328 | 328 | |
329 | 329 | // Create Give plugin roles |
330 | 330 | $roles = new Give_Roles(); |
@@ -335,4 +335,4 @@ discard block |
||
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
339 | 338 | \ No newline at end of file |
339 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
340 | 340 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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,14 +32,14 @@ discard block |
||
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( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
42 | - $price_id = isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | + $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
43 | 43 | |
44 | 44 | // Collect payment data. |
45 | 45 | $payment_data = array( |
@@ -57,69 +57,69 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment. |
60 | - $payment = give_insert_payment( $payment_data ); |
|
60 | + $payment = give_insert_payment($payment_data); |
|
61 | 61 | |
62 | 62 | // Check payment. |
63 | - if ( ! $payment ) { |
|
63 | + if ( ! $payment) { |
|
64 | 64 | // Record the error. |
65 | 65 | give_record_gateway_error( |
66 | - esc_html__( 'Payment Error', 'give' ), |
|
66 | + esc_html__('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment |
73 | 73 | ); |
74 | 74 | // Problems? Send back. |
75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
76 | 76 | |
77 | 77 | } else { |
78 | 78 | |
79 | 79 | // Only send to PayPal if the pending payment is created successfully. |
80 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
80 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
81 | 81 | |
82 | 82 | // Get the success url |
83 | - $return_url = add_query_arg( array( |
|
83 | + $return_url = add_query_arg(array( |
|
84 | 84 | 'payment-confirmation' => 'paypal', |
85 | 85 | 'payment-id' => $payment |
86 | 86 | |
87 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
87 | + ), get_permalink(give_get_option('success_page'))); |
|
88 | 88 | |
89 | 89 | // Get the PayPal redirect uri |
90 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
90 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
91 | 91 | |
92 | 92 | //Item name - pass level name if variable priced |
93 | 93 | $item_name = $purchase_data['post_data']['give-form-title']; |
94 | 94 | |
95 | 95 | //Verify has variable prices |
96 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
96 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
97 | 97 | |
98 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
98 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
100 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
101 | 101 | |
102 | 102 | //Donation given doesn't match selected level (must be a custom amount) |
103 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
104 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
103 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
104 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
105 | 105 | //user custom amount text if any, fallback to default if not |
106 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
106 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
107 | 107 | |
108 | 108 | } //Is there any donation level text? |
109 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
110 | - $item_name .= ' - ' . $item_price_level_text; |
|
109 | + elseif ( ! empty($item_price_level_text)) { |
|
110 | + $item_name .= ' - '.$item_price_level_text; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } //Single donation: Custom Amount |
114 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
115 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
114 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
115 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
116 | 116 | //user custom amount text if any, fallback to default if not |
117 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
117 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Setup PayPal arguments |
121 | 121 | $paypal_args = array( |
122 | - 'business' => give_get_option( 'paypal_email', false ), |
|
122 | + 'business' => give_get_option('paypal_email', false), |
|
123 | 123 | 'first_name' => $purchase_data['user_info']['first_name'], |
124 | 124 | 'last_name' => $purchase_data['user_info']['last_name'], |
125 | 125 | 'email' => $purchase_data['user_email'], |
@@ -132,28 +132,28 @@ discard block |
||
132 | 132 | 'shipping' => '0', |
133 | 133 | 'no_note' => '1', |
134 | 134 | 'currency_code' => give_get_currency(), |
135 | - 'charset' => get_bloginfo( 'charset' ), |
|
135 | + 'charset' => get_bloginfo('charset'), |
|
136 | 136 | 'custom' => $payment, |
137 | 137 | 'rm' => '2', |
138 | 138 | 'return' => $return_url, |
139 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
139 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
140 | 140 | 'notify_url' => $listener_url, |
141 | 141 | 'page_style' => give_get_paypal_page_style(), |
142 | - 'cbt' => get_bloginfo( 'name' ), |
|
142 | + 'cbt' => get_bloginfo('name'), |
|
143 | 143 | 'bn' => 'givewp_SP' |
144 | 144 | ); |
145 | 145 | |
146 | 146 | //Add user address if present. |
147 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
148 | - $paypal_args['address1'] = isset( $purchase_data['user_info']['address']['line1'] ) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
149 | - $paypal_args['address2'] = isset( $purchase_data['user_info']['address']['line2'] ) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
150 | - $paypal_args['city'] = isset( $purchase_data['user_info']['address']['city'] ) ? $purchase_data['user_info']['address']['city'] : ''; |
|
151 | - $paypal_args['state'] = isset( $purchase_data['user_info']['address']['state'] ) ? $purchase_data['user_info']['address']['state'] : ''; |
|
152 | - $paypal_args['country'] = isset( $purchase_data['user_info']['address']['country'] ) ? $purchase_data['user_info']['address']['country'] : ''; |
|
147 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
148 | + $paypal_args['address1'] = isset($purchase_data['user_info']['address']['line1']) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
149 | + $paypal_args['address2'] = isset($purchase_data['user_info']['address']['line2']) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
150 | + $paypal_args['city'] = isset($purchase_data['user_info']['address']['city']) ? $purchase_data['user_info']['address']['city'] : ''; |
|
151 | + $paypal_args['state'] = isset($purchase_data['user_info']['address']['state']) ? $purchase_data['user_info']['address']['state'] : ''; |
|
152 | + $paypal_args['country'] = isset($purchase_data['user_info']['address']['country']) ? $purchase_data['user_info']['address']['country'] : ''; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | //Donations or regular transactions? |
156 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
156 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
157 | 157 | $paypal_extra_args = array( |
158 | 158 | 'cmd' => '_xclick', |
159 | 159 | ); |
@@ -163,23 +163,23 @@ discard block |
||
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
167 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
166 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
167 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
168 | 168 | |
169 | 169 | // Build query |
170 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
170 | + $paypal_redirect .= http_build_query($paypal_args); |
|
171 | 171 | |
172 | 172 | // Fix for some sites that encode the entities |
173 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
173 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
174 | 174 | |
175 | 175 | // Redirect to PayPal |
176 | - wp_redirect( $paypal_redirect ); |
|
176 | + wp_redirect($paypal_redirect); |
|
177 | 177 | exit; |
178 | 178 | } |
179 | 179 | |
180 | 180 | } |
181 | 181 | |
182 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
182 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | */ |
190 | 190 | function give_listen_for_paypal_ipn() { |
191 | 191 | // Regular PayPal IPN |
192 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
193 | - do_action( 'give_verify_paypal_ipn' ); |
|
192 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
193 | + do_action('give_verify_paypal_ipn'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
197 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process PayPal IPN |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | function give_process_paypal_ipn() { |
206 | 206 | |
207 | 207 | // Check the request method is POST |
208 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
208 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | $post_data = ''; |
214 | 214 | |
215 | 215 | // Fallback just in case post_max_size is lower than needed |
216 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
217 | - $post_data = file_get_contents( 'php://input' ); |
|
216 | + if (ini_get('allow_url_fopen')) { |
|
217 | + $post_data = file_get_contents('php://input'); |
|
218 | 218 | } else { |
219 | 219 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
220 | - ini_set( 'post_max_size', '12M' ); |
|
220 | + ini_set('post_max_size', '12M'); |
|
221 | 221 | } |
222 | 222 | // Start the encoded data collection with notification command |
223 | 223 | $encoded_data = 'cmd=_notify-validate'; |
@@ -226,40 +226,40 @@ discard block |
||
226 | 226 | $arg_separator = give_get_php_arg_separator_output(); |
227 | 227 | |
228 | 228 | // Verify there is a post_data |
229 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
229 | + if ($post_data || strlen($post_data) > 0) { |
|
230 | 230 | // Append the data |
231 | - $encoded_data .= $arg_separator . $post_data; |
|
231 | + $encoded_data .= $arg_separator.$post_data; |
|
232 | 232 | } else { |
233 | 233 | // Check if POST is empty |
234 | - if ( empty( $_POST ) ) { |
|
234 | + if (empty($_POST)) { |
|
235 | 235 | // Nothing to do |
236 | 236 | return; |
237 | 237 | } else { |
238 | 238 | // Loop through each POST |
239 | - foreach ( $_POST as $key => $value ) { |
|
239 | + foreach ($_POST as $key => $value) { |
|
240 | 240 | // Encode the value and append the data |
241 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
241 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | 246 | // Convert collected post data to an array |
247 | - parse_str( $encoded_data, $encoded_data_array ); |
|
247 | + parse_str($encoded_data, $encoded_data_array); |
|
248 | 248 | |
249 | - foreach ( $encoded_data_array as $key => $value ) { |
|
249 | + foreach ($encoded_data_array as $key => $value) { |
|
250 | 250 | |
251 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
252 | - $new_key = str_replace( '&', '&', $key ); |
|
253 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
251 | + if (false !== strpos($key, 'amp;')) { |
|
252 | + $new_key = str_replace('&', '&', $key); |
|
253 | + $new_key = str_replace('amp;', '&', $new_key); |
|
254 | 254 | |
255 | - unset( $encoded_data_array[ $key ] ); |
|
256 | - $encoded_data_array[ $new_key ] = $value; |
|
255 | + unset($encoded_data_array[$key]); |
|
256 | + $encoded_data_array[$new_key] = $value; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | } |
260 | 260 | |
261 | 261 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
262 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
262 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
263 | 263 | |
264 | 264 | $remote_post_vars = array( |
265 | 265 | 'method' => 'POST', |
@@ -279,28 +279,28 @@ discard block |
||
279 | 279 | ); |
280 | 280 | |
281 | 281 | // Validate the IPN |
282 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
282 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
283 | 283 | |
284 | - if ( is_wp_error( $api_response ) ) { |
|
284 | + if (is_wp_error($api_response)) { |
|
285 | 285 | give_record_gateway_error( |
286 | - esc_html__( 'IPN Error', 'give' ), |
|
286 | + esc_html__('IPN Error', 'give'), |
|
287 | 287 | sprintf( |
288 | 288 | /* translators: %s: Paypal IPN response */ |
289 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
290 | - json_encode( $api_response ) |
|
289 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
290 | + json_encode($api_response) |
|
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | 294 | return; // Something went wrong |
295 | 295 | } |
296 | 296 | |
297 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
297 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
298 | 298 | give_record_gateway_error( |
299 | - esc_html__( 'IPN Error', 'give' ), |
|
299 | + esc_html__('IPN Error', 'give'), |
|
300 | 300 | sprintf( |
301 | 301 | /* translators: %s: Paypal IPN response */ |
302 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
303 | - json_encode( $api_response ) |
|
302 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
303 | + json_encode($api_response) |
|
304 | 304 | ) |
305 | 305 | ); |
306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | // Check if $post_data_array has been populated |
313 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
313 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
@@ -319,21 +319,21 @@ discard block |
||
319 | 319 | 'payment_status' => '' |
320 | 320 | ); |
321 | 321 | |
322 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
322 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
323 | 323 | |
324 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
324 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
325 | 325 | |
326 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
326 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
327 | 327 | // Allow PayPal IPN types to be processed separately |
328 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
328 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
329 | 329 | } else { |
330 | 330 | // Fallback to web accept just in case the txn_type isn't present |
331 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
331 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
332 | 332 | } |
333 | 333 | exit; |
334 | 334 | } |
335 | 335 | |
336 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
336 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Process web accept (one time) payment IPNs. |
@@ -344,224 +344,224 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @return void |
346 | 346 | */ |
347 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
347 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
348 | 348 | |
349 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
349 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
350 | 350 | return; |
351 | 351 | } |
352 | 352 | |
353 | - if ( empty( $payment_id ) ) { |
|
353 | + if (empty($payment_id)) { |
|
354 | 354 | return; |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Collect payment details |
358 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
358 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
359 | 359 | $paypal_amount = $data['mc_gross']; |
360 | - $payment_status = strtolower( $data['payment_status'] ); |
|
361 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
362 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
363 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
360 | + $payment_status = strtolower($data['payment_status']); |
|
361 | + $currency_code = strtolower($data['mc_currency']); |
|
362 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
363 | + $payment_meta = give_get_payment_meta($payment_id); |
|
364 | 364 | |
365 | 365 | |
366 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
366 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
367 | 367 | return; // this isn't a PayPal standard IPN |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Verify payment recipient |
371 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
371 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
372 | 372 | |
373 | 373 | give_record_gateway_error( |
374 | - esc_html__( 'IPN Error', 'give' ), |
|
374 | + esc_html__('IPN Error', 'give'), |
|
375 | 375 | sprintf( |
376 | 376 | /* translators: %s: Paypal IPN response */ |
377 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
378 | - json_encode( $data ) |
|
377 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
378 | + json_encode($data) |
|
379 | 379 | ), |
380 | 380 | $payment_id |
381 | 381 | ); |
382 | - give_update_payment_status( $payment_id, 'failed' ); |
|
383 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
382 | + give_update_payment_status($payment_id, 'failed'); |
|
383 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
384 | 384 | |
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Verify payment currency. |
389 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
389 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
390 | 390 | |
391 | 391 | give_record_gateway_error( |
392 | - esc_html__( 'IPN Error', 'give' ), |
|
392 | + esc_html__('IPN Error', 'give'), |
|
393 | 393 | sprintf( |
394 | 394 | /* translators: %s: Paypal IPN response */ |
395 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
396 | - json_encode( $data ) |
|
395 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
396 | + json_encode($data) |
|
397 | 397 | ), |
398 | 398 | $payment_id |
399 | 399 | ); |
400 | - give_update_payment_status( $payment_id, 'failed' ); |
|
401 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
400 | + give_update_payment_status($payment_id, 'failed'); |
|
401 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
402 | 402 | |
403 | 403 | return; |
404 | 404 | } |
405 | 405 | |
406 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
406 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
407 | 407 | |
408 | 408 | // No email associated with donation, so store email from PayPal. |
409 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
409 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
410 | 410 | |
411 | 411 | // Setup and store the donors's details. |
412 | 412 | $address = array(); |
413 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
414 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
415 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
416 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
417 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
413 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
414 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
415 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
416 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
417 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
418 | 418 | |
419 | 419 | $user_info = array( |
420 | 420 | 'id' => '-1', |
421 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
422 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
423 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
421 | + 'email' => sanitize_text_field($data['payer_email']), |
|
422 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
423 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
424 | 424 | 'discount' => '', |
425 | 425 | 'address' => $address |
426 | 426 | ); |
427 | 427 | |
428 | 428 | $payment_meta['user_info'] = $user_info; |
429 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
429 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
430 | 430 | } |
431 | 431 | |
432 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
432 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
433 | 433 | |
434 | 434 | // Process a refund |
435 | - give_process_paypal_refund( $data, $payment_id ); |
|
435 | + give_process_paypal_refund($data, $payment_id); |
|
436 | 436 | |
437 | 437 | } else { |
438 | 438 | |
439 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
439 | + if (get_post_status($payment_id) == 'publish') { |
|
440 | 440 | return; // Only complete payments once |
441 | 441 | } |
442 | 442 | |
443 | 443 | // Retrieve the total purchase amount (before PayPal) |
444 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
444 | + $payment_amount = give_get_payment_amount($payment_id); |
|
445 | 445 | |
446 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
446 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
447 | 447 | // The prices don't match |
448 | 448 | give_record_gateway_error( |
449 | - esc_html__( 'IPN Error', 'give' ), |
|
449 | + esc_html__('IPN Error', 'give'), |
|
450 | 450 | sprintf( |
451 | 451 | /* translators: %s: Paypal IPN response */ |
452 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
453 | - json_encode( $data ) |
|
452 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
453 | + json_encode($data) |
|
454 | 454 | ), |
455 | 455 | $payment_id |
456 | 456 | ); |
457 | - give_update_payment_status( $payment_id, 'failed' ); |
|
458 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
457 | + give_update_payment_status($payment_id, 'failed'); |
|
458 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
459 | 459 | |
460 | 460 | return; |
461 | 461 | } |
462 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
462 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
463 | 463 | // Purchase keys don't match |
464 | 464 | give_record_gateway_error( |
465 | - esc_html__( 'IPN Error', 'give' ), |
|
465 | + esc_html__('IPN Error', 'give'), |
|
466 | 466 | sprintf( |
467 | 467 | /* translators: %s: Paypal IPN response */ |
468 | - esc_html__( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
469 | - json_encode( $data ) |
|
468 | + esc_html__('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
469 | + json_encode($data) |
|
470 | 470 | ), |
471 | 471 | $payment_id |
472 | 472 | ); |
473 | - give_update_payment_status( $payment_id, 'failed' ); |
|
474 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
473 | + give_update_payment_status($payment_id, 'failed'); |
|
474 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
475 | 475 | |
476 | 476 | return; |
477 | 477 | } |
478 | 478 | |
479 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
479 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
480 | 480 | give_insert_payment_note( |
481 | 481 | $payment_id, |
482 | 482 | sprintf( |
483 | 483 | /* translators: %s: Paypal transaction ID */ |
484 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
484 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
485 | 485 | $data['txn_id'] |
486 | 486 | ) |
487 | 487 | ); |
488 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
489 | - give_update_payment_status( $payment_id, 'publish' ); |
|
490 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
488 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
489 | + give_update_payment_status($payment_id, 'publish'); |
|
490 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
491 | 491 | |
492 | 492 | // Look for possible pending reasons, such as an echeck |
493 | 493 | |
494 | 494 | $note = ''; |
495 | 495 | |
496 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
496 | + switch (strtolower($data['pending_reason'])) { |
|
497 | 497 | |
498 | 498 | case 'echeck' : |
499 | 499 | |
500 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
500 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
501 | 501 | |
502 | 502 | break; |
503 | 503 | |
504 | 504 | case 'address' : |
505 | 505 | |
506 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
506 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
507 | 507 | |
508 | 508 | break; |
509 | 509 | |
510 | 510 | case 'intl' : |
511 | 511 | |
512 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
512 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
513 | 513 | |
514 | 514 | break; |
515 | 515 | |
516 | 516 | case 'multi-currency' : |
517 | 517 | |
518 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
518 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
519 | 519 | |
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'paymentreview' : |
523 | 523 | case 'regulatory_review' : |
524 | 524 | |
525 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
525 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
526 | 526 | |
527 | 527 | break; |
528 | 528 | |
529 | 529 | case 'unilateral' : |
530 | 530 | |
531 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
531 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
532 | 532 | |
533 | 533 | break; |
534 | 534 | |
535 | 535 | case 'upgrade' : |
536 | 536 | |
537 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
537 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
538 | 538 | |
539 | 539 | break; |
540 | 540 | |
541 | 541 | case 'verify' : |
542 | 542 | |
543 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
543 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
544 | 544 | |
545 | 545 | break; |
546 | 546 | |
547 | 547 | case 'other' : |
548 | 548 | |
549 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
549 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
550 | 550 | |
551 | 551 | break; |
552 | 552 | |
553 | 553 | } |
554 | 554 | |
555 | - if ( ! empty( $note ) ) { |
|
555 | + if ( ! empty($note)) { |
|
556 | 556 | |
557 | - give_insert_payment_note( $payment_id, $note ); |
|
557 | + give_insert_payment_note($payment_id, $note); |
|
558 | 558 | |
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
563 | 563 | |
564 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
564 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
565 | 565 | |
566 | 566 | /** |
567 | 567 | * Process PayPal IPN Refunds |
@@ -572,28 +572,28 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return void |
574 | 574 | */ |
575 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
575 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
576 | 576 | |
577 | 577 | // Collect payment details |
578 | 578 | |
579 | - if ( empty( $payment_id ) ) { |
|
579 | + if (empty($payment_id)) { |
|
580 | 580 | return; |
581 | 581 | } |
582 | 582 | |
583 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
583 | + if (get_post_status($payment_id) == 'refunded') { |
|
584 | 584 | return; // Only refund payments once |
585 | 585 | } |
586 | 586 | |
587 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
587 | + $payment_amount = give_get_payment_amount($payment_id); |
|
588 | 588 | $refund_amount = $data['payment_gross'] * - 1; |
589 | 589 | |
590 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
590 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
591 | 591 | |
592 | 592 | give_insert_payment_note( |
593 | 593 | $payment_id, |
594 | 594 | sprintf( |
595 | 595 | /* translators: %s: Paypal parent transaction ID */ |
596 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
596 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
597 | 597 | $data['parent_txn_id'] |
598 | 598 | ) |
599 | 599 | ); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $payment_id, |
607 | 607 | sprintf( |
608 | 608 | /* translators: %s: Paypal parent transaction ID */ |
609 | - esc_html__( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
609 | + esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
610 | 610 | $data['parent_txn_id'], $data['reason_code'] |
611 | 611 | ) |
612 | 612 | ); |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | $payment_id, |
615 | 615 | sprintf( |
616 | 616 | /* translators: %s: Paypal transaction ID */ |
617 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
617 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
618 | 618 | $data['txn_id'] |
619 | 619 | ) |
620 | 620 | ); |
621 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
621 | + give_update_payment_status($payment_id, 'refunded'); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -630,24 +630,24 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return string |
632 | 632 | */ |
633 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
633 | +function give_get_paypal_redirect($ssl_check = false) { |
|
634 | 634 | |
635 | - if ( is_ssl() || ! $ssl_check ) { |
|
635 | + if (is_ssl() || ! $ssl_check) { |
|
636 | 636 | $protocal = 'https://'; |
637 | 637 | } else { |
638 | 638 | $protocal = 'http://'; |
639 | 639 | } |
640 | 640 | |
641 | 641 | // Check the current payment mode |
642 | - if ( give_is_test_mode() ) { |
|
642 | + if (give_is_test_mode()) { |
|
643 | 643 | // Test mode |
644 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
644 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
645 | 645 | } else { |
646 | 646 | // Live mode |
647 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
647 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
648 | 648 | } |
649 | 649 | |
650 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
650 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,9 +657,9 @@ discard block |
||
657 | 657 | * @return string |
658 | 658 | */ |
659 | 659 | function give_get_paypal_page_style() { |
660 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
660 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
661 | 661 | |
662 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
662 | + return apply_filters('give_paypal_page_style', $page_style); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -674,27 +674,27 @@ discard block |
||
674 | 674 | * @return string |
675 | 675 | * |
676 | 676 | */ |
677 | -function give_paypal_success_page_content( $content ) { |
|
677 | +function give_paypal_success_page_content($content) { |
|
678 | 678 | |
679 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
679 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
680 | 680 | return $content; |
681 | 681 | } |
682 | 682 | |
683 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
683 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
684 | 684 | |
685 | - if ( ! $payment_id ) { |
|
685 | + if ( ! $payment_id) { |
|
686 | 686 | $session = give_get_purchase_session(); |
687 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
687 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
688 | 688 | } |
689 | 689 | |
690 | - $payment = get_post( $payment_id ); |
|
690 | + $payment = get_post($payment_id); |
|
691 | 691 | |
692 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
692 | + if ($payment && 'pending' == $payment->post_status) { |
|
693 | 693 | |
694 | 694 | // Payment is still pending so show processing indicator to fix the Race Condition |
695 | 695 | ob_start(); |
696 | 696 | |
697 | - give_get_template_part( 'payment', 'processing' ); |
|
697 | + give_get_template_part('payment', 'processing'); |
|
698 | 698 | |
699 | 699 | $content = ob_get_clean(); |
700 | 700 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | |
705 | 705 | } |
706 | 706 | |
707 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
707 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
708 | 708 | |
709 | 709 | /** |
710 | 710 | * Given a Payment ID, extract the transaction ID |
@@ -715,22 +715,22 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return string Transaction ID |
717 | 717 | */ |
718 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
718 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
719 | 719 | |
720 | 720 | $transaction_id = ''; |
721 | - $notes = give_get_payment_notes( $payment_id ); |
|
721 | + $notes = give_get_payment_notes($payment_id); |
|
722 | 722 | |
723 | - foreach ( $notes as $note ) { |
|
724 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
723 | + foreach ($notes as $note) { |
|
724 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
725 | 725 | $transaction_id = $match[1]; |
726 | 726 | continue; |
727 | 727 | } |
728 | 728 | } |
729 | 729 | |
730 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
730 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
731 | 731 | } |
732 | 732 | |
733 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
733 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
734 | 734 | |
735 | 735 | /** |
736 | 736 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -742,13 +742,13 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @return string A link to the PayPal transaction details |
744 | 744 | */ |
745 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
745 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
746 | 746 | |
747 | 747 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
748 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
748 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
749 | 749 | |
750 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
750 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
751 | 751 | |
752 | 752 | } |
753 | 753 | |
754 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
754 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |