@@ -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 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array $output Response messages |
25 | 25 | */ |
26 | -function give_edit_customer( $args ) { |
|
26 | +function give_edit_customer($args) { |
|
27 | 27 | |
28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( empty( $args ) ) { |
|
34 | + if (empty($args)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
40 | 40 | $nonce = $args['_wpnonce']; |
41 | 41 | |
42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
43 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
44 | 44 | } |
45 | 45 | |
46 | - $customer = new Give_Customer( $customer_id ); |
|
47 | - if ( empty( $customer->id ) ) { |
|
46 | + $customer = new Give_Customer($customer_id); |
|
47 | + if (empty($customer->id)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | 'user_id' => 0 |
55 | 55 | ); |
56 | 56 | |
57 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
57 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
58 | 58 | |
59 | - if ( ! is_email( $customer_info['email'] ) ) { |
|
60 | - give_set_error( 'give-invalid-email', __( 'Please enter a valid email address.', 'give' ) ); |
|
59 | + if ( ! is_email($customer_info['email'])) { |
|
60 | + give_set_error('give-invalid-email', __('Please enter a valid email address.', 'give')); |
|
61 | 61 | } |
62 | 62 | |
63 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
63 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a customer |
66 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( __( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
66 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-customer-user_id', sprintf(__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user |
71 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
72 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $customer_info['user_id']); |
|
72 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -78,82 +78,82 @@ discard block |
||
78 | 78 | // Record this for later |
79 | 79 | $previous_user_id = $customer->user_id; |
80 | 80 | |
81 | - if ( give_get_errors() ) { |
|
81 | + if (give_get_errors()) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Setup the customer address, if present |
86 | 86 | $address = array(); |
87 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
87 | + if (intval($customer_info['user_id']) > 0) { |
|
88 | 88 | |
89 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
89 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
90 | 90 | |
91 | - if ( false === $current_address ) { |
|
92 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
93 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
94 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
95 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
96 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
97 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
91 | + if (false === $current_address) { |
|
92 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
93 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
94 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
95 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
96 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
97 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
98 | 98 | } else { |
99 | - $current_address = wp_parse_args( $current_address, array( |
|
99 | + $current_address = wp_parse_args($current_address, array( |
|
100 | 100 | 'line1', |
101 | 101 | 'line2', |
102 | 102 | 'city', |
103 | 103 | 'zip', |
104 | 104 | 'state', |
105 | 105 | 'country' |
106 | - ) ); |
|
107 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
110 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
111 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
106 | + )); |
|
107 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
110 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
111 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Sanitize the inputs |
118 | 118 | $customer_data = array(); |
119 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
119 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
120 | 120 | $customer_data['email'] = $customer_info['email']; |
121 | 121 | $customer_data['user_id'] = $customer_info['user_id']; |
122 | 122 | |
123 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
124 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
123 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
124 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
125 | 125 | |
126 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
127 | - $address = array_map( 'sanitize_text_field', $address ); |
|
126 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
127 | + $address = array_map('sanitize_text_field', $address); |
|
128 | 128 | |
129 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
129 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
130 | 130 | |
131 | 131 | $output = array(); |
132 | 132 | $previous_email = $customer->email; |
133 | 133 | |
134 | - if ( $customer->update( $customer_data ) ) { |
|
134 | + if ($customer->update($customer_data)) { |
|
135 | 135 | |
136 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
137 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
136 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
137 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Update some payment meta if we need to |
141 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
141 | + $payments_array = explode(',', $customer->payment_ids); |
|
142 | 142 | |
143 | - if ( $customer->email != $previous_email ) { |
|
144 | - foreach ( $payments_array as $payment_id ) { |
|
145 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
143 | + if ($customer->email != $previous_email) { |
|
144 | + foreach ($payments_array as $payment_id) { |
|
145 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ( $customer->user_id != $previous_user_id ) { |
|
150 | - foreach ( $payments_array as $payment_id ) { |
|
151 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
149 | + if ($customer->user_id != $previous_user_id) { |
|
150 | + foreach ($payments_array as $payment_id) { |
|
151 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | $output['success'] = true; |
156 | - $customer_data = array_merge( $customer_data, $address ); |
|
156 | + $customer_data = array_merge($customer_data, $address); |
|
157 | 157 | $output['customer_info'] = $customer_data; |
158 | 158 | |
159 | 159 | } else { |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
165 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
166 | 166 | |
167 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
168 | - header( 'Content-Type: application/json' ); |
|
169 | - echo json_encode( $output ); |
|
167 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
168 | + header('Content-Type: application/json'); |
|
169 | + echo json_encode($output); |
|
170 | 170 | wp_die(); |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | } |
176 | 176 | |
177 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
177 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Save a customer note being added |
@@ -185,53 +185,53 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return int The Note ID that was saved, or 0 if nothing was saved |
187 | 187 | */ |
188 | -function give_customer_save_note( $args ) { |
|
188 | +function give_customer_save_note($args) { |
|
189 | 189 | |
190 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
190 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
191 | 191 | |
192 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
193 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
192 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
193 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
194 | 194 | } |
195 | 195 | |
196 | - if ( empty( $args ) ) { |
|
196 | + if (empty($args)) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
200 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
201 | 201 | $customer_id = (int) $args['customer_id']; |
202 | 202 | $nonce = $args['add_customer_note_nonce']; |
203 | 203 | |
204 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
205 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
204 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
205 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( empty( $customer_note ) ) { |
|
209 | - give_set_error( 'empty-customer-note', __( 'A note is required.', 'give' ) ); |
|
208 | + if (empty($customer_note)) { |
|
209 | + give_set_error('empty-customer-note', __('A note is required.', 'give')); |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( give_get_errors() ) { |
|
212 | + if (give_get_errors()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $customer = new Give_Customer( $customer_id ); |
|
217 | - $new_note = $customer->add_note( $customer_note ); |
|
216 | + $customer = new Give_Customer($customer_id); |
|
217 | + $new_note = $customer->add_note($customer_note); |
|
218 | 218 | |
219 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
219 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
220 | 220 | |
221 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
221 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
222 | 222 | |
223 | 223 | ob_start(); |
224 | 224 | ?> |
225 | 225 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
226 | 226 | <span class="note-content-wrap"> |
227 | - <?php echo stripslashes( $new_note ); ?> |
|
227 | + <?php echo stripslashes($new_note); ?> |
|
228 | 228 | </span> |
229 | 229 | </div> |
230 | 230 | <?php |
231 | 231 | $output = ob_get_contents(); |
232 | 232 | ob_end_clean(); |
233 | 233 | |
234 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
234 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
235 | 235 | echo $output; |
236 | 236 | exit; |
237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | } |
246 | 246 | |
247 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
247 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Delete a customer |
@@ -255,87 +255,87 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return int Whether it was a successful deletion |
257 | 257 | */ |
258 | -function give_customer_delete( $args ) { |
|
258 | +function give_customer_delete($args) { |
|
259 | 259 | |
260 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
260 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
261 | 261 | |
262 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
263 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ) ); |
|
262 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
263 | + wp_die(__('You do not have permission to delete donors.', 'give')); |
|
264 | 264 | } |
265 | 265 | |
266 | - if ( empty( $args ) ) { |
|
266 | + if (empty($args)) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $customer_id = (int) $args['customer_id']; |
271 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
272 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
271 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
272 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
273 | 273 | $nonce = $args['_wpnonce']; |
274 | 274 | |
275 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
276 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
275 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
276 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
277 | 277 | } |
278 | 278 | |
279 | - if ( ! $confirm ) { |
|
280 | - give_set_error( 'customer-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
279 | + if ( ! $confirm) { |
|
280 | + give_set_error('customer-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
281 | 281 | } |
282 | 282 | |
283 | - if ( give_get_errors() ) { |
|
284 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
283 | + if (give_get_errors()) { |
|
284 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
285 | 285 | exit; |
286 | 286 | } |
287 | 287 | |
288 | - $customer = new Give_Customer( $customer_id ); |
|
288 | + $customer = new Give_Customer($customer_id); |
|
289 | 289 | |
290 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
290 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
291 | 291 | |
292 | 292 | $success = false; |
293 | 293 | |
294 | - if ( $customer->id > 0 ) { |
|
294 | + if ($customer->id > 0) { |
|
295 | 295 | |
296 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
297 | - $success = Give()->customers->delete( $customer->id ); |
|
296 | + $payments_array = explode(',', $customer->payment_ids); |
|
297 | + $success = Give()->customers->delete($customer->id); |
|
298 | 298 | |
299 | - if ( $success ) { |
|
299 | + if ($success) { |
|
300 | 300 | |
301 | - if ( $remove_data ) { |
|
301 | + if ($remove_data) { |
|
302 | 302 | |
303 | 303 | // Remove all payments, logs, etc |
304 | - foreach ( $payments_array as $payment_id ) { |
|
305 | - give_delete_purchase( $payment_id ); |
|
304 | + foreach ($payments_array as $payment_id) { |
|
305 | + give_delete_purchase($payment_id); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | } else { |
309 | 309 | |
310 | 310 | // Just set the payments to customer_id of 0 |
311 | - foreach ( $payments_array as $payment_id ) { |
|
312 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
311 | + foreach ($payments_array as $payment_id) { |
|
312 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
317 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
318 | 318 | |
319 | 319 | } else { |
320 | 320 | |
321 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) ); |
|
322 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
321 | + give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give')); |
|
322 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | 326 | } else { |
327 | 327 | |
328 | - give_set_error( 'give-customer-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) ); |
|
329 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
328 | + give_set_error('give-customer-delete-invalid-id', __('Invalid Donor ID.', 'give')); |
|
329 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | |
333 | - wp_redirect( $redirect ); |
|
333 | + wp_redirect($redirect); |
|
334 | 334 | exit; |
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
338 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Disconnect a user ID from a donor |
@@ -346,39 +346,39 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool If the disconnect was successful |
348 | 348 | */ |
349 | -function give_disconnect_customer_user_id( $args ) { |
|
349 | +function give_disconnect_customer_user_id($args) { |
|
350 | 350 | |
351 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
351 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
352 | 352 | |
353 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
354 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ) ); |
|
353 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
354 | + wp_die(__('You do not have permission to edit this donor.', 'give')); |
|
355 | 355 | } |
356 | 356 | |
357 | - if ( empty( $args ) ) { |
|
357 | + if (empty($args)) { |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | 361 | $customer_id = (int) $args['customer_id']; |
362 | 362 | $nonce = $args['_wpnonce']; |
363 | 363 | |
364 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
365 | - wp_die( __( 'Cheatin\' eh?!', 'give' ) ); |
|
364 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
365 | + wp_die(__('Cheatin\' eh?!', 'give')); |
|
366 | 366 | } |
367 | 367 | |
368 | - $customer = new Give_Customer( $customer_id ); |
|
369 | - if ( empty( $customer->id ) ) { |
|
368 | + $customer = new Give_Customer($customer_id); |
|
369 | + if (empty($customer->id)) { |
|
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | |
373 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id ); |
|
373 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id); |
|
374 | 374 | |
375 | - $customer_args = array( 'user_id' => 0 ); |
|
375 | + $customer_args = array('user_id' => 0); |
|
376 | 376 | |
377 | - if ( $customer->update( $customer_args ) ) { |
|
377 | + if ($customer->update($customer_args)) { |
|
378 | 378 | global $wpdb; |
379 | 379 | |
380 | - if ( ! empty( $customer->payment_ids ) ) { |
|
381 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
380 | + if ( ! empty($customer->payment_ids)) { |
|
381 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | $output['success'] = true; |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | } else { |
387 | 387 | |
388 | 388 | $output['success'] = false; |
389 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
389 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
390 | 390 | } |
391 | 391 | |
392 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
392 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
393 | 393 | |
394 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
395 | - header( 'Content-Type: application/json' ); |
|
396 | - echo json_encode( $output ); |
|
394 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
395 | + header('Content-Type: application/json'); |
|
396 | + echo json_encode($output); |
|
397 | 397 | wp_die(); |
398 | 398 | } |
399 | 399 | |
@@ -401,4 +401,4 @@ discard block |
||
401 | 401 | |
402 | 402 | } |
403 | 403 | |
404 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
404 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
@@ -13,328 +13,328 @@ |
||
13 | 13 | * @version 1.6 |
14 | 14 | */ |
15 | 15 | class EDD_SL_Plugin_Updater { |
16 | - private $api_url = ''; |
|
17 | - private $api_data = array(); |
|
18 | - private $name = ''; |
|
19 | - private $slug = ''; |
|
20 | - |
|
21 | - /** |
|
22 | - * Class constructor. |
|
23 | - * |
|
24 | - * @uses plugin_basename() |
|
25 | - * @uses hook() |
|
26 | - * |
|
27 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | - * @param string $_plugin_file Path to the plugin file. |
|
29 | - * @param array $_api_data Optional data to send with API calls. |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
34 | - $this->api_data = $_api_data; |
|
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | - $this->version = $_api_data['version']; |
|
38 | - |
|
39 | - // Set up hooks. |
|
40 | - $this->init(); |
|
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Set up WordPress filters to hook into WP's update process. |
|
46 | - * |
|
47 | - * @uses add_filter() |
|
48 | - * |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function init() { |
|
16 | + private $api_url = ''; |
|
17 | + private $api_data = array(); |
|
18 | + private $name = ''; |
|
19 | + private $slug = ''; |
|
20 | + |
|
21 | + /** |
|
22 | + * Class constructor. |
|
23 | + * |
|
24 | + * @uses plugin_basename() |
|
25 | + * @uses hook() |
|
26 | + * |
|
27 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | + * @param string $_plugin_file Path to the plugin file. |
|
29 | + * @param array $_api_data Optional data to send with API calls. |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | + $this->api_url = trailingslashit( $_api_url ); |
|
34 | + $this->api_data = $_api_data; |
|
35 | + $this->name = plugin_basename( $_plugin_file ); |
|
36 | + $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | + $this->version = $_api_data['version']; |
|
38 | + |
|
39 | + // Set up hooks. |
|
40 | + $this->init(); |
|
41 | + add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Set up WordPress filters to hook into WP's update process. |
|
46 | + * |
|
47 | + * @uses add_filter() |
|
48 | + * |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function init() { |
|
52 | 52 | |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
55 | 55 | |
56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | - } |
|
56 | + add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | - * |
|
62 | - * This function dives into the update API just when WordPress creates its update array, |
|
63 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | - * |
|
67 | - * @uses api_request() |
|
68 | - * |
|
69 | - * @param array $_transient_data Update array build by WordPress. |
|
70 | - * @return array Modified update array with custom plugin data. |
|
71 | - */ |
|
72 | - function check_update( $_transient_data ) { |
|
59 | + /** |
|
60 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | + * |
|
62 | + * This function dives into the update API just when WordPress creates its update array, |
|
63 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | + * |
|
67 | + * @uses api_request() |
|
68 | + * |
|
69 | + * @param array $_transient_data Update array build by WordPress. |
|
70 | + * @return array Modified update array with custom plugin data. |
|
71 | + */ |
|
72 | + function check_update( $_transient_data ) { |
|
73 | 73 | |
74 | - global $pagenow; |
|
74 | + global $pagenow; |
|
75 | 75 | |
76 | - if( ! is_object( $_transient_data ) ) { |
|
77 | - $_transient_data = new stdClass; |
|
78 | - } |
|
76 | + if( ! is_object( $_transient_data ) ) { |
|
77 | + $_transient_data = new stdClass; |
|
78 | + } |
|
79 | 79 | |
80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | - return $_transient_data; |
|
82 | - } |
|
80 | + if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | + return $_transient_data; |
|
82 | + } |
|
83 | 83 | |
84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
85 | 85 | |
86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
87 | 87 | |
88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
89 | 89 | |
90 | - $this->did_check = true; |
|
90 | + $this->did_check = true; |
|
91 | 91 | |
92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
92 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
93 | 93 | |
94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
94 | + $_transient_data->response[ $this->name ] = $version_info; |
|
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - $_transient_data->last_checked = time(); |
|
99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
98 | + $_transient_data->last_checked = time(); |
|
99 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | 100 | |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - return $_transient_data; |
|
106 | - } |
|
105 | + return $_transient_data; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | - * |
|
111 | - * @param string $file |
|
112 | - * @param array $plugin |
|
113 | - */ |
|
114 | - public function show_update_notification( $file, $plugin ) { |
|
108 | + /** |
|
109 | + * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | + * |
|
111 | + * @param string $file |
|
112 | + * @param array $plugin |
|
113 | + */ |
|
114 | + public function show_update_notification( $file, $plugin ) { |
|
115 | 115 | |
116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | - return; |
|
118 | - } |
|
116 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | + return; |
|
118 | + } |
|
119 | 119 | |
120 | - if( ! is_multisite() ) { |
|
121 | - return; |
|
122 | - } |
|
120 | + if( ! is_multisite() ) { |
|
121 | + return; |
|
122 | + } |
|
123 | 123 | |
124 | - if ( $this->name != $file ) { |
|
125 | - return; |
|
126 | - } |
|
124 | + if ( $this->name != $file ) { |
|
125 | + return; |
|
126 | + } |
|
127 | 127 | |
128 | - // Remove our filter on the site transient |
|
129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
128 | + // Remove our filter on the site transient |
|
129 | + remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
130 | 130 | |
131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
131 | + $update_cache = get_site_transient( 'update_plugins' ); |
|
132 | 132 | |
133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
133 | + if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
134 | 134 | |
135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | - $version_info = get_transient( $cache_key ); |
|
135 | + $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | + $version_info = get_transient( $cache_key ); |
|
137 | 137 | |
138 | - if( false === $version_info ) { |
|
138 | + if( false === $version_info ) { |
|
139 | 139 | |
140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
140 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
141 | 141 | |
142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
143 | - } |
|
142 | + set_transient( $cache_key, $version_info, 3600 ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - if( ! is_object( $version_info ) ) { |
|
147 | - return; |
|
148 | - } |
|
146 | + if( ! is_object( $version_info ) ) { |
|
147 | + return; |
|
148 | + } |
|
149 | 149 | |
150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
150 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
151 | 151 | |
152 | - $update_cache->response[ $this->name ] = $version_info; |
|
152 | + $update_cache->response[ $this->name ] = $version_info; |
|
153 | 153 | |
154 | - } |
|
154 | + } |
|
155 | 155 | |
156 | - $update_cache->last_checked = time(); |
|
157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
156 | + $update_cache->last_checked = time(); |
|
157 | + $update_cache->checked[ $this->name ] = $this->version; |
|
158 | 158 | |
159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
159 | + set_site_transient( 'update_plugins', $update_cache ); |
|
160 | 160 | |
161 | - } else { |
|
161 | + } else { |
|
162 | 162 | |
163 | - $version_info = $update_cache->response[ $this->name ]; |
|
163 | + $version_info = $update_cache->response[ $this->name ]; |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - // Restore our filter |
|
168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
167 | + // Restore our filter |
|
168 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
169 | 169 | |
170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
170 | + if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
171 | 171 | |
172 | - // build a plugin list row, with update notification |
|
173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
172 | + // build a plugin list row, with update notification |
|
173 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | + echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
175 | 175 | |
176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
176 | + $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
177 | 177 | |
178 | - if ( empty( $version_info->download_link ) ) { |
|
179 | - printf( |
|
180 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
181 | - esc_html( $version_info->name ), |
|
182 | - esc_url( $changelog_link ), |
|
183 | - esc_html( $version_info->new_version ) |
|
184 | - ); |
|
185 | - } else { |
|
186 | - printf( |
|
187 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
188 | - esc_html( $version_info->name ), |
|
189 | - esc_url( $changelog_link ), |
|
190 | - esc_html( $version_info->new_version ), |
|
191 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
192 | - ); |
|
193 | - } |
|
178 | + if ( empty( $version_info->download_link ) ) { |
|
179 | + printf( |
|
180 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
181 | + esc_html( $version_info->name ), |
|
182 | + esc_url( $changelog_link ), |
|
183 | + esc_html( $version_info->new_version ) |
|
184 | + ); |
|
185 | + } else { |
|
186 | + printf( |
|
187 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
188 | + esc_html( $version_info->name ), |
|
189 | + esc_url( $changelog_link ), |
|
190 | + esc_html( $version_info->new_version ), |
|
191 | + esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
192 | + ); |
|
193 | + } |
|
194 | 194 | |
195 | - echo '</div></td></tr>'; |
|
196 | - } |
|
197 | - } |
|
195 | + echo '</div></td></tr>'; |
|
196 | + } |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * Updates information on the "View version x.x details" page with custom data. |
|
202 | - * |
|
203 | - * @uses api_request() |
|
204 | - * |
|
205 | - * @param mixed $_data |
|
206 | - * @param string $_action |
|
207 | - * @param object $_args |
|
208 | - * @return object $_data |
|
209 | - */ |
|
210 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
200 | + /** |
|
201 | + * Updates information on the "View version x.x details" page with custom data. |
|
202 | + * |
|
203 | + * @uses api_request() |
|
204 | + * |
|
205 | + * @param mixed $_data |
|
206 | + * @param string $_action |
|
207 | + * @param object $_args |
|
208 | + * @return object $_data |
|
209 | + */ |
|
210 | + function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
211 | 211 | |
212 | 212 | |
213 | - if ( $_action != 'plugin_information' ) { |
|
213 | + if ( $_action != 'plugin_information' ) { |
|
214 | 214 | |
215 | - return $_data; |
|
215 | + return $_data; |
|
216 | 216 | |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
219 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
220 | 220 | |
221 | - return $_data; |
|
221 | + return $_data; |
|
222 | 222 | |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - $to_send = array( |
|
226 | - 'slug' => $this->slug, |
|
227 | - 'is_ssl' => is_ssl(), |
|
228 | - 'fields' => array( |
|
229 | - 'banners' => false, // These will be supported soon hopefully |
|
230 | - 'reviews' => false |
|
231 | - ) |
|
232 | - ); |
|
225 | + $to_send = array( |
|
226 | + 'slug' => $this->slug, |
|
227 | + 'is_ssl' => is_ssl(), |
|
228 | + 'fields' => array( |
|
229 | + 'banners' => false, // These will be supported soon hopefully |
|
230 | + 'reviews' => false |
|
231 | + ) |
|
232 | + ); |
|
233 | 233 | |
234 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
234 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
235 | 235 | |
236 | - if ( false !== $api_response ) { |
|
237 | - $_data = $api_response; |
|
238 | - } |
|
236 | + if ( false !== $api_response ) { |
|
237 | + $_data = $api_response; |
|
238 | + } |
|
239 | 239 | |
240 | - return $_data; |
|
241 | - } |
|
240 | + return $_data; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | - /** |
|
245 | - * Disable SSL verification in order to prevent download update failures |
|
246 | - * |
|
247 | - * @param array $args |
|
248 | - * @param string $url |
|
249 | - * @return object $array |
|
250 | - */ |
|
251 | - function http_request_args( $args, $url ) { |
|
252 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
253 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | - $args['sslverify'] = false; |
|
255 | - } |
|
256 | - return $args; |
|
257 | - } |
|
244 | + /** |
|
245 | + * Disable SSL verification in order to prevent download update failures |
|
246 | + * |
|
247 | + * @param array $args |
|
248 | + * @param string $url |
|
249 | + * @return object $array |
|
250 | + */ |
|
251 | + function http_request_args( $args, $url ) { |
|
252 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
253 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | + $args['sslverify'] = false; |
|
255 | + } |
|
256 | + return $args; |
|
257 | + } |
|
258 | 258 | |
259 | - /** |
|
260 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
261 | - * |
|
262 | - * @uses get_bloginfo() |
|
263 | - * @uses wp_remote_post() |
|
264 | - * @uses is_wp_error() |
|
265 | - * |
|
266 | - * @param string $_action The requested action. |
|
267 | - * @param array $_data Parameters for the API action. |
|
268 | - * @return false||object |
|
269 | - */ |
|
270 | - private function api_request( $_action, $_data ) { |
|
271 | - |
|
272 | - global $wp_version; |
|
273 | - |
|
274 | - $data = array_merge( $this->api_data, $_data ); |
|
275 | - |
|
276 | - if ( $data['slug'] != $this->slug ) |
|
277 | - return; |
|
278 | - |
|
279 | - if ( empty( $data['license'] ) ) |
|
280 | - return; |
|
281 | - |
|
282 | - if( $this->api_url == home_url() ) { |
|
283 | - return false; // Don't allow a plugin to ping itself |
|
284 | - } |
|
285 | - |
|
286 | - $api_params = array( |
|
287 | - 'edd_action' => 'get_version', |
|
288 | - 'license' => $data['license'], |
|
289 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
290 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
291 | - 'slug' => $data['slug'], |
|
292 | - 'author' => $data['author'], |
|
293 | - 'url' => home_url() |
|
294 | - ); |
|
259 | + /** |
|
260 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
261 | + * |
|
262 | + * @uses get_bloginfo() |
|
263 | + * @uses wp_remote_post() |
|
264 | + * @uses is_wp_error() |
|
265 | + * |
|
266 | + * @param string $_action The requested action. |
|
267 | + * @param array $_data Parameters for the API action. |
|
268 | + * @return false||object |
|
269 | + */ |
|
270 | + private function api_request( $_action, $_data ) { |
|
271 | + |
|
272 | + global $wp_version; |
|
273 | + |
|
274 | + $data = array_merge( $this->api_data, $_data ); |
|
275 | + |
|
276 | + if ( $data['slug'] != $this->slug ) |
|
277 | + return; |
|
278 | + |
|
279 | + if ( empty( $data['license'] ) ) |
|
280 | + return; |
|
281 | + |
|
282 | + if( $this->api_url == home_url() ) { |
|
283 | + return false; // Don't allow a plugin to ping itself |
|
284 | + } |
|
285 | + |
|
286 | + $api_params = array( |
|
287 | + 'edd_action' => 'get_version', |
|
288 | + 'license' => $data['license'], |
|
289 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
290 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
291 | + 'slug' => $data['slug'], |
|
292 | + 'author' => $data['author'], |
|
293 | + 'url' => home_url() |
|
294 | + ); |
|
295 | 295 | |
296 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
296 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
297 | 297 | |
298 | - if ( ! is_wp_error( $request ) ) { |
|
299 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
300 | - } |
|
298 | + if ( ! is_wp_error( $request ) ) { |
|
299 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
300 | + } |
|
301 | 301 | |
302 | - if ( $request && isset( $request->sections ) ) { |
|
303 | - $request->sections = maybe_unserialize( $request->sections ); |
|
304 | - } else { |
|
305 | - $request = false; |
|
306 | - } |
|
302 | + if ( $request && isset( $request->sections ) ) { |
|
303 | + $request->sections = maybe_unserialize( $request->sections ); |
|
304 | + } else { |
|
305 | + $request = false; |
|
306 | + } |
|
307 | 307 | |
308 | - return $request; |
|
309 | - } |
|
308 | + return $request; |
|
309 | + } |
|
310 | 310 | |
311 | - public function show_changelog() { |
|
311 | + public function show_changelog() { |
|
312 | 312 | |
313 | 313 | |
314 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
315 | - return; |
|
316 | - } |
|
314 | + if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
319 | - return; |
|
320 | - } |
|
321 | - |
|
322 | - if( empty( $_REQUEST['slug'] ) ) { |
|
323 | - return; |
|
324 | - } |
|
325 | - |
|
326 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
327 | - wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
328 | - } |
|
329 | - |
|
330 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
331 | - |
|
332 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
333 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - exit; |
|
338 | - } |
|
318 | + if( empty( $_REQUEST['plugin'] ) ) { |
|
319 | + return; |
|
320 | + } |
|
321 | + |
|
322 | + if( empty( $_REQUEST['slug'] ) ) { |
|
323 | + return; |
|
324 | + } |
|
325 | + |
|
326 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
327 | + wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
328 | + } |
|
329 | + |
|
330 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
331 | + |
|
332 | + if( $response && isset( $response->sections['changelog'] ) ) { |
|
333 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + exit; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined('ABSPATH')) exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Allows plugins to use their own update API. |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param array $_api_data Optional data to send with API calls. |
30 | 30 | * @return void |
31 | 31 | */ |
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
32 | + function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
33 | + $this->api_url = trailingslashit($_api_url); |
|
34 | 34 | $this->api_data = $_api_data; |
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
35 | + $this->name = plugin_basename($_plugin_file); |
|
36 | + $this->slug = basename($_plugin_file, '.php'); |
|
37 | 37 | $this->version = $_api_data['version']; |
38 | 38 | |
39 | 39 | // Set up hooks. |
40 | 40 | $this->init(); |
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
41 | + add_action('admin_init', array($this, 'show_changelog')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init() { |
52 | 52 | |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
54 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
55 | 55 | |
56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
56 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -69,34 +69,34 @@ discard block |
||
69 | 69 | * @param array $_transient_data Update array build by WordPress. |
70 | 70 | * @return array Modified update array with custom plugin data. |
71 | 71 | */ |
72 | - function check_update( $_transient_data ) { |
|
72 | + function check_update($_transient_data) { |
|
73 | 73 | |
74 | 74 | global $pagenow; |
75 | 75 | |
76 | - if( ! is_object( $_transient_data ) ) { |
|
76 | + if ( ! is_object($_transient_data)) { |
|
77 | 77 | $_transient_data = new stdClass; |
78 | 78 | } |
79 | 79 | |
80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
80 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
81 | 81 | return $_transient_data; |
82 | 82 | } |
83 | 83 | |
84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
85 | 85 | |
86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
87 | 87 | |
88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
89 | 89 | |
90 | 90 | $this->did_check = true; |
91 | 91 | |
92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
92 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
93 | 93 | |
94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
94 | + $_transient_data->response[$this->name] = $version_info; |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | 98 | $_transient_data->last_checked = time(); |
99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
99 | + $_transient_data->checked[$this->name] = $this->version; |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -111,84 +111,84 @@ discard block |
||
111 | 111 | * @param string $file |
112 | 112 | * @param array $plugin |
113 | 113 | */ |
114 | - public function show_update_notification( $file, $plugin ) { |
|
114 | + public function show_update_notification($file, $plugin) { |
|
115 | 115 | |
116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
116 | + if ( ! current_user_can('update_plugins')) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | 119 | |
120 | - if( ! is_multisite() ) { |
|
120 | + if ( ! is_multisite()) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | - if ( $this->name != $file ) { |
|
124 | + if ($this->name != $file) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Remove our filter on the site transient |
129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
129 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
130 | 130 | |
131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
131 | + $update_cache = get_site_transient('update_plugins'); |
|
132 | 132 | |
133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
133 | + if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
134 | 134 | |
135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | - $version_info = get_transient( $cache_key ); |
|
135 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
136 | + $version_info = get_transient($cache_key); |
|
137 | 137 | |
138 | - if( false === $version_info ) { |
|
138 | + if (false === $version_info) { |
|
139 | 139 | |
140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
140 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
141 | 141 | |
142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
142 | + set_transient($cache_key, $version_info, 3600); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - if( ! is_object( $version_info ) ) { |
|
146 | + if ( ! is_object($version_info)) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
150 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
151 | 151 | |
152 | - $update_cache->response[ $this->name ] = $version_info; |
|
152 | + $update_cache->response[$this->name] = $version_info; |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | 156 | $update_cache->last_checked = time(); |
157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
157 | + $update_cache->checked[$this->name] = $this->version; |
|
158 | 158 | |
159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
159 | + set_site_transient('update_plugins', $update_cache); |
|
160 | 160 | |
161 | 161 | } else { |
162 | 162 | |
163 | - $version_info = $update_cache->response[ $this->name ]; |
|
163 | + $version_info = $update_cache->response[$this->name]; |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Restore our filter |
168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
168 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
169 | 169 | |
170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
170 | + if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
171 | 171 | |
172 | 172 | // build a plugin list row, with update notification |
173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
173 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
174 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
175 | 175 | |
176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
176 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
177 | 177 | |
178 | - if ( empty( $version_info->download_link ) ) { |
|
178 | + if (empty($version_info->download_link)) { |
|
179 | 179 | printf( |
180 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
181 | - esc_html( $version_info->name ), |
|
182 | - esc_url( $changelog_link ), |
|
183 | - esc_html( $version_info->new_version ) |
|
180 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'), |
|
181 | + esc_html($version_info->name), |
|
182 | + esc_url($changelog_link), |
|
183 | + esc_html($version_info->new_version) |
|
184 | 184 | ); |
185 | 185 | } else { |
186 | 186 | printf( |
187 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
188 | - esc_html( $version_info->name ), |
|
189 | - esc_url( $changelog_link ), |
|
190 | - esc_html( $version_info->new_version ), |
|
191 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
187 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd'), |
|
188 | + esc_html($version_info->name), |
|
189 | + esc_url($changelog_link), |
|
190 | + esc_html($version_info->new_version), |
|
191 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | * @param object $_args |
208 | 208 | * @return object $_data |
209 | 209 | */ |
210 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
210 | + function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
211 | 211 | |
212 | 212 | |
213 | - if ( $_action != 'plugin_information' ) { |
|
213 | + if ($_action != 'plugin_information') { |
|
214 | 214 | |
215 | 215 | return $_data; |
216 | 216 | |
217 | 217 | } |
218 | 218 | |
219 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
219 | + if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
220 | 220 | |
221 | 221 | return $_data; |
222 | 222 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | |
234 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
234 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
235 | 235 | |
236 | - if ( false !== $api_response ) { |
|
236 | + if (false !== $api_response) { |
|
237 | 237 | $_data = $api_response; |
238 | 238 | } |
239 | 239 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param string $url |
249 | 249 | * @return object $array |
250 | 250 | */ |
251 | - function http_request_args( $args, $url ) { |
|
251 | + function http_request_args($args, $url) { |
|
252 | 252 | // If it is an https request and we are performing a package download, disable ssl verification |
253 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
253 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
254 | 254 | $args['sslverify'] = false; |
255 | 255 | } |
256 | 256 | return $args; |
@@ -267,40 +267,40 @@ discard block |
||
267 | 267 | * @param array $_data Parameters for the API action. |
268 | 268 | * @return false||object |
269 | 269 | */ |
270 | - private function api_request( $_action, $_data ) { |
|
270 | + private function api_request($_action, $_data) { |
|
271 | 271 | |
272 | 272 | global $wp_version; |
273 | 273 | |
274 | - $data = array_merge( $this->api_data, $_data ); |
|
274 | + $data = array_merge($this->api_data, $_data); |
|
275 | 275 | |
276 | - if ( $data['slug'] != $this->slug ) |
|
276 | + if ($data['slug'] != $this->slug) |
|
277 | 277 | return; |
278 | 278 | |
279 | - if ( empty( $data['license'] ) ) |
|
279 | + if (empty($data['license'])) |
|
280 | 280 | return; |
281 | 281 | |
282 | - if( $this->api_url == home_url() ) { |
|
282 | + if ($this->api_url == home_url()) { |
|
283 | 283 | return false; // Don't allow a plugin to ping itself |
284 | 284 | } |
285 | 285 | |
286 | 286 | $api_params = array( |
287 | 287 | 'edd_action' => 'get_version', |
288 | 288 | 'license' => $data['license'], |
289 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
290 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
289 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
290 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
291 | 291 | 'slug' => $data['slug'], |
292 | 292 | 'author' => $data['author'], |
293 | 293 | 'url' => home_url() |
294 | 294 | ); |
295 | 295 | |
296 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
296 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
297 | 297 | |
298 | - if ( ! is_wp_error( $request ) ) { |
|
299 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
298 | + if ( ! is_wp_error($request)) { |
|
299 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( $request && isset( $request->sections ) ) { |
|
303 | - $request->sections = maybe_unserialize( $request->sections ); |
|
302 | + if ($request && isset($request->sections)) { |
|
303 | + $request->sections = maybe_unserialize($request->sections); |
|
304 | 304 | } else { |
305 | 305 | $request = false; |
306 | 306 | } |
@@ -311,26 +311,26 @@ discard block |
||
311 | 311 | public function show_changelog() { |
312 | 312 | |
313 | 313 | |
314 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
314 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
318 | + if (empty($_REQUEST['plugin'])) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | - if( empty( $_REQUEST['slug'] ) ) { |
|
322 | + if (empty($_REQUEST['slug'])) { |
|
323 | 323 | return; |
324 | 324 | } |
325 | 325 | |
326 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
327 | - wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
326 | + if ( ! current_user_can('update_plugins')) { |
|
327 | + wp_die(__('You do not have permission to install plugin updates.', 'edd'), __('Error', 'edd'), array('response' => 403)); |
|
328 | 328 | } |
329 | 329 | |
330 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
330 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
331 | 331 | |
332 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
333 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
332 | + if ($response && isset($response->sections['changelog'])) { |
|
333 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 |
@@ -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 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * @since 1.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
31 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
32 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 ); |
|
30 | + add_action('admin_notices', array($this, 'show_notices')); |
|
31 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
32 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | public function give_admin_bar_menu() { |
43 | 43 | global $wp_admin_bar; |
44 | 44 | |
45 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
45 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | //Add the main siteadmin menu item |
50 | - $wp_admin_bar->add_menu( array( |
|
50 | + $wp_admin_bar->add_menu(array( |
|
51 | 51 | 'id' => 'give-test-notice', |
52 | - 'href' => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
52 | + 'href' => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
53 | 53 | 'parent' => 'top-secondary', |
54 | - 'title' => __( 'Give Test Mode Active', 'give' ), |
|
55 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
56 | - ) ); |
|
54 | + 'title' => __('Give Test Mode Active', 'give'), |
|
55 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -68,97 +68,97 @@ discard block |
||
68 | 68 | 'error' => array() |
69 | 69 | ); |
70 | 70 | |
71 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
71 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
72 | 72 | echo '<div class="error">'; |
73 | - echo '<p>' . __( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
74 | - echo '<p>' . sprintf( esc_attr__( 'Please see %1$sthis reference%2$s for possible solutions.', 'give' ), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>' ) . '</p>'; |
|
75 | - echo '<p><a href="' . add_query_arg( array( |
|
73 | + echo '<p>'.__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
74 | + echo '<p>'.sprintf(esc_attr__('Please see %1$sthis reference%2$s for possible solutions.', 'give'), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>').'</p>'; |
|
75 | + echo '<p><a href="'.add_query_arg(array( |
|
76 | 76 | 'give_action' => 'dismiss_notices', |
77 | 77 | 'give_notice' => 'admin_ajax_inaccessible' |
78 | - ) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
78 | + )).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>'; |
|
79 | 79 | echo '</div>'; |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - if ( isset( $_GET['give-message'] ) ) { |
|
83 | + if (isset($_GET['give-message'])) { |
|
84 | 84 | |
85 | 85 | // Donation reports errors |
86 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
87 | - switch ( $_GET['give-message'] ) { |
|
86 | + if (current_user_can('view_give_reports')) { |
|
87 | + switch ($_GET['give-message']) { |
|
88 | 88 | case 'payment_deleted' : |
89 | - $notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' ); |
|
89 | + $notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give'); |
|
90 | 90 | break; |
91 | 91 | case 'email_sent' : |
92 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
92 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
93 | 93 | break; |
94 | 94 | case 'refreshed-reports' : |
95 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
95 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
96 | 96 | break; |
97 | 97 | case 'payment-note-deleted' : |
98 | - $notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' ); |
|
98 | + $notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give'); |
|
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Give settings notices and errors |
104 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
105 | - switch ( $_GET['give-message'] ) { |
|
104 | + if (current_user_can('manage_give_settings')) { |
|
105 | + switch ($_GET['give-message']) { |
|
106 | 106 | case 'settings-imported' : |
107 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
107 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
108 | 108 | break; |
109 | 109 | case 'api-key-generated' : |
110 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' ); |
|
110 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give'); |
|
111 | 111 | break; |
112 | 112 | case 'api-key-exists' : |
113 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
113 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
114 | 114 | break; |
115 | 115 | case 'api-key-regenerated' : |
116 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' ); |
|
116 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give'); |
|
117 | 117 | break; |
118 | 118 | case 'api-key-revoked' : |
119 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' ); |
|
119 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give'); |
|
120 | 120 | break; |
121 | 121 | case 'sent-test-email' : |
122 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
122 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
123 | 123 | break; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | // Payments errors |
127 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
128 | - switch ( $_GET['give-message'] ) { |
|
127 | + if (current_user_can('edit_give_payments')) { |
|
128 | + switch ($_GET['give-message']) { |
|
129 | 129 | case 'note-added' : |
130 | - $notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' ); |
|
130 | + $notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give'); |
|
131 | 131 | break; |
132 | 132 | case 'payment-updated' : |
133 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' ); |
|
133 | + $notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give'); |
|
134 | 134 | break; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Customer Notices |
139 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
140 | - switch ( $_GET['give-message'] ) { |
|
139 | + if (current_user_can('edit_give_payments')) { |
|
140 | + switch ($_GET['give-message']) { |
|
141 | 141 | case 'customer-deleted' : |
142 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted.', 'give' ); |
|
142 | + $notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted.', 'give'); |
|
143 | 143 | break; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | - if ( count( $notices['updated'] ) > 0 ) { |
|
150 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
151 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
149 | + if (count($notices['updated']) > 0) { |
|
150 | + foreach ($notices['updated'] as $notice => $message) { |
|
151 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - if ( count( $notices['error'] ) > 0 ) { |
|
156 | - foreach ( $notices['error'] as $notice => $message ) { |
|
157 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
155 | + if (count($notices['error']) > 0) { |
|
156 | + foreach ($notices['error'] as $notice => $message) { |
|
157 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - settings_errors( 'give-notices' ); |
|
161 | + settings_errors('give-notices'); |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function give_admin_addons_notices() { |
173 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
174 | - settings_errors( 'give-notices' ); |
|
173 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
174 | + settings_errors('give-notices'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | function dismiss_notices() { |
185 | - if ( isset( $_GET['give_notice'] ) ) { |
|
186 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
187 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
185 | + if (isset($_GET['give_notice'])) { |
|
186 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
187 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
188 | 188 | exit; |
189 | 189 | } |
190 | 190 | } |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function __construct() { |
51 | 51 | |
52 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
52 | + add_action('admin_init', array($this, 'init')); |
|
53 | 53 | |
54 | 54 | //Customize CMB2 URL |
55 | - add_filter( 'cmb2_meta_box_url', array( $this, 'give_update_cmb_meta_box_url' ) ); |
|
55 | + add_filter('cmb2_meta_box_url', array($this, 'give_update_cmb_meta_box_url')); |
|
56 | 56 | |
57 | 57 | //Custom CMB2 Settings Fields |
58 | - add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 ); |
|
59 | - add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 ); |
|
60 | - add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 ); |
|
61 | - add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 ); |
|
62 | - add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 ); |
|
63 | - add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 ); |
|
64 | - add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 ); |
|
65 | - add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 ); |
|
66 | - add_action( 'admin_notices', array( $this, 'settings_notices' ) ); |
|
58 | + add_action('cmb2_render_give_title', 'give_title_callback', 10, 5); |
|
59 | + add_action('cmb2_render_give_description', 'give_description_callback', 10, 5); |
|
60 | + add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5); |
|
61 | + add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5); |
|
62 | + add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5); |
|
63 | + add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5); |
|
64 | + add_action('cmb2_render_api', 'give_api_callback', 10, 5); |
|
65 | + add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5); |
|
66 | + add_action('admin_notices', array($this, 'settings_notices')); |
|
67 | 67 | |
68 | 68 | // Include CMB CSS in the head to avoid FOUC |
69 | - add_action( 'admin_print_styles-give_forms_page_give-settings', array( 'CMB2_hookup', 'enqueue_cmb_css' ) ); |
|
69 | + add_action('admin_print_styles-give_forms_page_give-settings', array('CMB2_hookup', 'enqueue_cmb_css')); |
|
70 | 70 | |
71 | - add_filter( 'cmb2_get_metabox_form_format', array( $this, 'give_modify_cmb2_form_output' ), 10, 3 ); |
|
71 | + add_filter('cmb2_get_metabox_form_format', array($this, 'give_modify_cmb2_form_output'), 10, 3); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @since 1.0 |
79 | 79 | */ |
80 | 80 | public function init() { |
81 | - register_setting( $this->key, $this->key ); |
|
81 | + register_setting($this->key, $this->key); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - public function give_update_cmb_meta_box_url( $url ) { |
|
95 | + public function give_update_cmb_meta_box_url($url) { |
|
96 | 96 | //Path to Give's CMB |
97 | - return GIVE_PLUGIN_URL . '/includes/libraries/cmb2'; |
|
97 | + return GIVE_PLUGIN_URL.'/includes/libraries/cmb2'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,27 +106,27 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function give_get_settings_tabs() { |
108 | 108 | |
109 | - $settings = $this->give_settings( null ); |
|
109 | + $settings = $this->give_settings(null); |
|
110 | 110 | |
111 | 111 | $tabs = array(); |
112 | - $tabs['general'] = __( 'General', 'give' ); |
|
113 | - $tabs['gateways'] = __( 'Payment Gateways', 'give' ); |
|
114 | - $tabs['display'] = __( 'Display Options', 'give' ); |
|
115 | - $tabs['emails'] = __( 'Emails', 'give' ); |
|
112 | + $tabs['general'] = __('General', 'give'); |
|
113 | + $tabs['gateways'] = __('Payment Gateways', 'give'); |
|
114 | + $tabs['display'] = __('Display Options', 'give'); |
|
115 | + $tabs['emails'] = __('Emails', 'give'); |
|
116 | 116 | |
117 | - if ( ! empty( $settings['addons']['fields'] ) ) { |
|
118 | - $tabs['addons'] = __( 'Add-ons', 'give' ); |
|
117 | + if ( ! empty($settings['addons']['fields'])) { |
|
118 | + $tabs['addons'] = __('Add-ons', 'give'); |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( ! empty( $settings['licenses']['fields'] ) ) { |
|
122 | - $tabs['licenses'] = __( 'Licenses', 'give' ); |
|
121 | + if ( ! empty($settings['licenses']['fields'])) { |
|
122 | + $tabs['licenses'] = __('Licenses', 'give'); |
|
123 | 123 | } |
124 | 124 | |
125 | - $tabs['advanced'] = __( 'Advanced', 'give' ); |
|
126 | - $tabs['api'] = __( 'API', 'give' ); |
|
127 | - $tabs['system_info'] = __( 'System Info', 'give' ); |
|
125 | + $tabs['advanced'] = __('Advanced', 'give'); |
|
126 | + $tabs['api'] = __('API', 'give'); |
|
127 | + $tabs['system_info'] = __('System Info', 'give'); |
|
128 | 128 | |
129 | - return apply_filters( 'give_settings_tabs', $tabs ); |
|
129 | + return apply_filters('give_settings_tabs', $tabs); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function admin_page_display() { |
138 | 138 | |
139 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general'; |
|
139 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general'; |
|
140 | 140 | |
141 | 141 | ?> |
142 | 142 | |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | |
145 | 145 | <h1 class="nav-tab-wrapper"> |
146 | 146 | <?php |
147 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
147 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
148 | 148 | |
149 | 149 | //Support legacy tab creation conditions based off $_GET parameter |
150 | 150 | //We pass the $_GET['tab'] to conditions executed later |
151 | 151 | $_GET['tab'] = $tab_id; |
152 | 152 | |
153 | - $tab_url = esc_url( add_query_arg( array( |
|
153 | + $tab_url = esc_url(add_query_arg(array( |
|
154 | 154 | 'settings-updated' => false, |
155 | 155 | 'tab' => $tab_id |
156 | - ) ) ); |
|
156 | + ))); |
|
157 | 157 | |
158 | - $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
|
158 | + $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
|
159 | 159 | |
160 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>'; |
|
160 | + echo '<a href="'.esc_url($tab_url).'" title="'.esc_attr($tab_name).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>'; |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | ?> |
@@ -165,20 +165,20 @@ discard block |
||
165 | 165 | |
166 | 166 | <?php |
167 | 167 | //Loop through and output settings |
168 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
168 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
169 | 169 | |
170 | 170 | //Support legacy tab creation conditions based off $_GET parameter |
171 | 171 | //We 'trick' the conditions into thinking this is the tab |
172 | 172 | $_GET['tab'] = $tab_id; |
173 | 173 | |
174 | - $tab_settings = $this->give_settings( $tab_id ); |
|
174 | + $tab_settings = $this->give_settings($tab_id); |
|
175 | 175 | |
176 | 176 | //Pass active tab within $tab_settings so we can hide with CSS via PHP |
177 | - if ( $active_tab == $tab_id ) { |
|
177 | + if ($active_tab == $tab_id) { |
|
178 | 178 | $tab_settings['active_tab'] = true; |
179 | 179 | } |
180 | 180 | |
181 | - cmb2_metabox_form( $tab_settings, $this->key ); |
|
181 | + cmb2_metabox_form($tab_settings, $this->key); |
|
182 | 182 | |
183 | 183 | } ?> |
184 | 184 | |
@@ -196,34 +196,34 @@ discard block |
||
196 | 196 | * @since 1.5 Modified to CSS hide non-active tabs |
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | - function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) { |
|
199 | + function give_modify_cmb2_form_output($form_format, $object_id, $cmb) { |
|
200 | 200 | |
201 | 201 | |
202 | - $pagenow = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
202 | + $pagenow = isset($_GET['page']) ? $_GET['page'] : ''; |
|
203 | 203 | |
204 | 204 | //only modify the give settings form |
205 | - if ( 'give_settings' == $object_id && $pagenow == 'give-settings' ) { |
|
205 | + if ('give_settings' == $object_id && $pagenow == 'give-settings') { |
|
206 | 206 | |
207 | 207 | $style = ''; |
208 | - if ( ! isset( $cmb->meta_box['active_tab'] ) ) { |
|
208 | + if ( ! isset($cmb->meta_box['active_tab'])) { |
|
209 | 209 | $style = 'style="display:none;"'; |
210 | 210 | } |
211 | 211 | |
212 | 212 | //Set ID based off tab name - protects backwards compatibility |
213 | - $tab_id = isset( $_GET['tab'] ) ? $_GET['tab'] : $cmb->meta_box['id']; |
|
213 | + $tab_id = isset($_GET['tab']) ? $_GET['tab'] : $cmb->meta_box['id']; |
|
214 | 214 | |
215 | - $save_button = apply_filters( 'give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . __( 'Save Settings', 'give' ) . '" class="button-primary"></div>' ); |
|
215 | + $save_button = apply_filters('give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.__('Save Settings', 'give').'" class="button-primary"></div>'); |
|
216 | 216 | |
217 | 217 | //Filter so some tabs won't have save settings |
218 | - $no_save_button = apply_filters( 'give_settings_no_save_output', array( |
|
218 | + $no_save_button = apply_filters('give_settings_no_save_output', array( |
|
219 | 219 | 'system_info' |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | - if ( in_array( $tab_id, $no_save_button ) ) { |
|
222 | + if (in_array($tab_id, $no_save_button)) { |
|
223 | 223 | $save_button = ''; |
224 | 224 | } |
225 | 225 | |
226 | - $form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" ' . $style . ' data-tab="' . $tab_id . '"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s' . $save_button . '</form>'; |
|
226 | + $form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" '.$style.' data-tab="'.$tab_id.'"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s'.$save_button.'</form>'; |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - public function give_settings( $active_tab ) { |
|
243 | + public function give_settings($active_tab) { |
|
244 | 244 | |
245 | 245 | $give_settings = array( |
246 | 246 | /** |
@@ -248,60 +248,60 @@ discard block |
||
248 | 248 | */ |
249 | 249 | 'general' => array( |
250 | 250 | 'id' => 'general_settings', |
251 | - 'give_title' => __( 'General Settings', 'give' ), |
|
252 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
253 | - 'fields' => apply_filters( 'give_settings_general', array( |
|
251 | + 'give_title' => __('General Settings', 'give'), |
|
252 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
253 | + 'fields' => apply_filters('give_settings_general', array( |
|
254 | 254 | array( |
255 | - 'name' => __( 'General Settings', 'give' ), |
|
255 | + 'name' => __('General Settings', 'give'), |
|
256 | 256 | 'desc' => '', |
257 | 257 | 'type' => 'give_title', |
258 | 258 | 'id' => 'give_title_general_settings_1' |
259 | 259 | ), |
260 | 260 | array( |
261 | - 'name' => __( 'Success Page', 'give' ), |
|
262 | - 'desc' => sprintf( __( 'This is the page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
261 | + 'name' => __('Success Page', 'give'), |
|
262 | + 'desc' => sprintf(__('This is the page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
263 | 263 | 'id' => 'success_page', |
264 | 264 | 'type' => 'select', |
265 | - 'options' => give_cmb2_get_post_options( array( |
|
265 | + 'options' => give_cmb2_get_post_options(array( |
|
266 | 266 | 'post_type' => 'page', |
267 | - 'numberposts' => - 1 |
|
268 | - ) ), |
|
267 | + 'numberposts' => -1 |
|
268 | + )), |
|
269 | 269 | ), |
270 | 270 | array( |
271 | - 'name' => __( 'Failed Transaction Page', 'give' ), |
|
272 | - 'desc' => __( 'This is the page donors are sent to if their transaction is cancelled or fails.', 'give' ), |
|
271 | + 'name' => __('Failed Transaction Page', 'give'), |
|
272 | + 'desc' => __('This is the page donors are sent to if their transaction is cancelled or fails.', 'give'), |
|
273 | 273 | 'id' => 'failure_page', |
274 | 274 | 'type' => 'select', |
275 | - 'options' => give_cmb2_get_post_options( array( |
|
275 | + 'options' => give_cmb2_get_post_options(array( |
|
276 | 276 | 'post_type' => 'page', |
277 | - 'numberposts' => - 1 |
|
278 | - ) ), |
|
277 | + 'numberposts' => -1 |
|
278 | + )), |
|
279 | 279 | ), |
280 | 280 | array( |
281 | - 'name' => __( 'Donation History Page', 'give' ), |
|
282 | - 'desc' => sprintf( __( 'This page shows a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
281 | + 'name' => __('Donation History Page', 'give'), |
|
282 | + 'desc' => sprintf(__('This page shows a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
283 | 283 | 'id' => 'history_page', |
284 | 284 | 'type' => 'select', |
285 | - 'options' => give_cmb2_get_post_options( array( |
|
285 | + 'options' => give_cmb2_get_post_options(array( |
|
286 | 286 | 'post_type' => 'page', |
287 | - 'numberposts' => - 1 |
|
288 | - ) ), |
|
287 | + 'numberposts' => -1 |
|
288 | + )), |
|
289 | 289 | ), |
290 | 290 | array( |
291 | - 'name' => __( 'Base Country', 'give' ), |
|
292 | - 'desc' => __( 'Where does your site operate from?', 'give' ), |
|
291 | + 'name' => __('Base Country', 'give'), |
|
292 | + 'desc' => __('Where does your site operate from?', 'give'), |
|
293 | 293 | 'id' => 'base_country', |
294 | 294 | 'type' => 'select', |
295 | 295 | 'options' => give_get_country_list(), |
296 | 296 | ), |
297 | 297 | array( |
298 | - 'name' => __( 'Currency Settings', 'give' ), |
|
298 | + 'name' => __('Currency Settings', 'give'), |
|
299 | 299 | 'desc' => '', |
300 | 300 | 'type' => 'give_title', |
301 | 301 | 'id' => 'give_title_general_settings_2' |
302 | 302 | ), |
303 | 303 | array( |
304 | - 'name' => __( 'Currency', 'give' ), |
|
304 | + 'name' => __('Currency', 'give'), |
|
305 | 305 | 'desc' => 'Choose your currency. Note that some payment gateways have currency restrictions.', |
306 | 306 | 'id' => 'currency', |
307 | 307 | 'type' => 'select', |
@@ -309,26 +309,26 @@ discard block |
||
309 | 309 | 'default' => 'USD', |
310 | 310 | ), |
311 | 311 | array( |
312 | - 'name' => __( 'Currency Position', 'give' ), |
|
312 | + 'name' => __('Currency Position', 'give'), |
|
313 | 313 | 'desc' => 'Choose the position of the currency sign.', |
314 | 314 | 'id' => 'currency_position', |
315 | 315 | 'type' => 'select', |
316 | 316 | 'options' => array( |
317 | - 'before' => sprintf( __( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
318 | - 'after' => sprintf( __( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ) |
|
317 | + 'before' => sprintf(__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())), |
|
318 | + 'after' => sprintf(__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())) |
|
319 | 319 | ), |
320 | 320 | 'default' => 'before', |
321 | 321 | ), |
322 | 322 | array( |
323 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
324 | - 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ), |
|
323 | + 'name' => __('Thousands Separator', 'give'), |
|
324 | + 'desc' => __('The symbol (typically , or .) to separate thousands.', 'give'), |
|
325 | 325 | 'id' => 'thousands_separator', |
326 | 326 | 'type' => 'text_small', |
327 | 327 | 'default' => ',', |
328 | 328 | ), |
329 | 329 | array( |
330 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
331 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
330 | + 'name' => __('Decimal Separator', 'give'), |
|
331 | + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
332 | 332 | 'id' => 'decimal_separator', |
333 | 333 | 'type' => 'text_small', |
334 | 334 | 'default' => '.', |
@@ -341,83 +341,83 @@ discard block |
||
341 | 341 | */ |
342 | 342 | 'gateways' => array( |
343 | 343 | 'id' => 'payment_gateways', |
344 | - 'give_title' => __( 'Payment Gateways', 'give' ), |
|
345 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
346 | - 'fields' => apply_filters( 'give_settings_gateways', array( |
|
344 | + 'give_title' => __('Payment Gateways', 'give'), |
|
345 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
346 | + 'fields' => apply_filters('give_settings_gateways', array( |
|
347 | 347 | array( |
348 | - 'name' => __( 'Gateways Settings', 'give' ), |
|
348 | + 'name' => __('Gateways Settings', 'give'), |
|
349 | 349 | 'desc' => '', |
350 | 350 | 'id' => 'give_title_gateway_settings_1', |
351 | 351 | 'type' => 'give_title' |
352 | 352 | ), |
353 | 353 | array( |
354 | - 'name' => __( 'Test Mode', 'give' ), |
|
355 | - 'desc' => __( 'While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
354 | + 'name' => __('Test Mode', 'give'), |
|
355 | + 'desc' => __('While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
356 | 356 | 'id' => 'test_mode', |
357 | 357 | 'type' => 'checkbox' |
358 | 358 | ), |
359 | 359 | array( |
360 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
361 | - 'desc' => __( 'Choose the payment gateways you would like enabled. You can drag-and-drop payment gateways to reorder them.', 'give' ), |
|
360 | + 'name' => __('Enabled Gateways', 'give'), |
|
361 | + 'desc' => __('Choose the payment gateways you would like enabled. You can drag-and-drop payment gateways to reorder them.', 'give'), |
|
362 | 362 | 'id' => 'gateways', |
363 | 363 | 'type' => 'enabled_gateways' |
364 | 364 | ), |
365 | 365 | array( |
366 | - 'name' => __( 'Default Gateway', 'give' ), |
|
367 | - 'desc' => __( 'This is the gateway that will be selected by default.', 'give' ), |
|
366 | + 'name' => __('Default Gateway', 'give'), |
|
367 | + 'desc' => __('This is the gateway that will be selected by default.', 'give'), |
|
368 | 368 | 'id' => 'default_gateway', |
369 | 369 | 'type' => 'default_gateway' |
370 | 370 | ), |
371 | 371 | array( |
372 | - 'name' => __( 'PayPal Standard', 'give' ), |
|
372 | + 'name' => __('PayPal Standard', 'give'), |
|
373 | 373 | 'desc' => '', |
374 | 374 | 'type' => 'give_title', |
375 | 375 | 'id' => 'give_title_gateway_settings_2', |
376 | 376 | ), |
377 | 377 | array( |
378 | - 'name' => __( 'PayPal Email', 'give' ), |
|
379 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
|
378 | + 'name' => __('PayPal Email', 'give'), |
|
379 | + 'desc' => __('Enter your PayPal account\'s email.', 'give'), |
|
380 | 380 | 'id' => 'paypal_email', |
381 | 381 | 'type' => 'text_email', |
382 | 382 | ), |
383 | 383 | array( |
384 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
385 | - 'desc' => __( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ), |
|
384 | + 'name' => __('PayPal Page Style', 'give'), |
|
385 | + 'desc' => __('Enter the name of the page style to use, or leave blank to use the default.', 'give'), |
|
386 | 386 | 'id' => 'paypal_page_style', |
387 | 387 | 'type' => 'text', |
388 | 388 | ), |
389 | 389 | array( |
390 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
391 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
390 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
391 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
392 | 392 | 'id' => 'paypal_button_type', |
393 | 393 | 'type' => 'radio_inline', |
394 | 394 | 'options' => array( |
395 | - 'donation' => __( 'Donation', 'give' ), |
|
396 | - 'standard' => __( 'Standard Transaction', 'give' ) |
|
395 | + 'donation' => __('Donation', 'give'), |
|
396 | + 'standard' => __('Standard Transaction', 'give') |
|
397 | 397 | ), |
398 | 398 | 'default' => 'donation', |
399 | 399 | ), |
400 | 400 | array( |
401 | - 'name' => __( 'Disable PayPal IPN Verification', 'give' ), |
|
402 | - 'desc' => __( 'If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give' ), |
|
401 | + 'name' => __('Disable PayPal IPN Verification', 'give'), |
|
402 | + 'desc' => __('If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give'), |
|
403 | 403 | 'id' => 'disable_paypal_verification', |
404 | 404 | 'type' => 'checkbox' |
405 | 405 | ), |
406 | 406 | array( |
407 | - 'name' => __( 'Offline Donations', 'give' ), |
|
407 | + 'name' => __('Offline Donations', 'give'), |
|
408 | 408 | 'desc' => '', |
409 | 409 | 'type' => 'give_title', |
410 | 410 | 'id' => 'give_title_gateway_settings_3', |
411 | 411 | ), |
412 | 412 | array( |
413 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
414 | - 'desc' => __( 'This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give' ), |
|
413 | + 'name' => __('Collect Billing Details', 'give'), |
|
414 | + 'desc' => __('This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give'), |
|
415 | 415 | 'id' => 'give_offline_donation_enable_billing_fields', |
416 | 416 | 'type' => 'checkbox' |
417 | 417 | ), |
418 | 418 | array( |
419 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
420 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
419 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
420 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
421 | 421 | 'id' => 'global_offline_donation_content', |
422 | 422 | 'default' => give_get_default_offline_donation_content(), |
423 | 423 | 'type' => 'wysiwyg', |
@@ -426,15 +426,15 @@ discard block |
||
426 | 426 | ) |
427 | 427 | ), |
428 | 428 | array( |
429 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
430 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
429 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
430 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
431 | 431 | 'id' => 'offline_donation_subject', |
432 | - 'default' => __( '{donation} - Offline Donation Instructions', 'give' ), |
|
432 | + 'default' => __('{donation} - Offline Donation Instructions', 'give'), |
|
433 | 433 | 'type' => 'text' |
434 | 434 | ), |
435 | 435 | array( |
436 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
437 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
436 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
437 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
438 | 438 | 'id' => 'global_offline_donation_email', |
439 | 439 | 'default' => give_get_default_offline_donation_email_content(), |
440 | 440 | 'type' => 'wysiwyg', |
@@ -448,93 +448,93 @@ discard block |
||
448 | 448 | /** Display Settings */ |
449 | 449 | 'display' => array( |
450 | 450 | 'id' => 'display_settings', |
451 | - 'give_title' => __( 'Display Settings', 'give' ), |
|
452 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
453 | - 'fields' => apply_filters( 'give_settings_display', array( |
|
451 | + 'give_title' => __('Display Settings', 'give'), |
|
452 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
453 | + 'fields' => apply_filters('give_settings_display', array( |
|
454 | 454 | array( |
455 | - 'name' => __( 'Display Settings', 'give' ), |
|
455 | + 'name' => __('Display Settings', 'give'), |
|
456 | 456 | 'desc' => '', |
457 | 457 | 'id' => 'give_title_display_settings_1', |
458 | 458 | 'type' => 'give_title' |
459 | 459 | ), |
460 | 460 | array( |
461 | - 'name' => __( 'Disable CSS', 'give' ), |
|
462 | - 'desc' => __( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ), |
|
461 | + 'name' => __('Disable CSS', 'give'), |
|
462 | + 'desc' => __('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'), |
|
463 | 463 | 'id' => 'disable_css', |
464 | 464 | 'type' => 'checkbox' |
465 | 465 | ), |
466 | 466 | array( |
467 | - 'name' => __( 'Enable Floating Labels', 'give' ), |
|
468 | - 'desc' => sprintf( esc_html__( 'Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), '<a href="' . esc_url( "http://bradfrost.com/blog/post/float-label-pattern/" ) . '" target="_blank">', '</a>', '<br />' ), |
|
467 | + 'name' => __('Enable Floating Labels', 'give'), |
|
468 | + 'desc' => sprintf(esc_html__('Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), '<a href="'.esc_url("http://bradfrost.com/blog/post/float-label-pattern/").'" target="_blank">', '</a>', '<br />'), |
|
469 | 469 | 'id' => 'enable_floatlabels', |
470 | 470 | 'type' => 'checkbox' |
471 | 471 | ), |
472 | 472 | array( |
473 | - 'name' => __( 'Disable Welcome Screen', 'give' ), |
|
474 | - 'desc' => sprintf( esc_html__( 'Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the <a href="%s">Welcome Screen</a> if you want in the future.', 'give' ), esc_url( admin_url( 'index.php?page=give-about' ) ) ), |
|
473 | + 'name' => __('Disable Welcome Screen', 'give'), |
|
474 | + 'desc' => sprintf(esc_html__('Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the <a href="%s">Welcome Screen</a> if you want in the future.', 'give'), esc_url(admin_url('index.php?page=give-about'))), |
|
475 | 475 | 'id' => 'disable_welcome', |
476 | 476 | 'type' => 'checkbox' |
477 | 477 | ), |
478 | 478 | array( |
479 | - 'name' => __( 'Post Types', 'give' ), |
|
479 | + 'name' => __('Post Types', 'give'), |
|
480 | 480 | 'desc' => '', |
481 | 481 | 'id' => 'give_title_display_settings_2', |
482 | 482 | 'type' => 'give_title' |
483 | 483 | ), |
484 | 484 | array( |
485 | - 'name' => __( 'Disable Form Single Views', 'give' ), |
|
486 | - 'desc' => __( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
485 | + 'name' => __('Disable Form Single Views', 'give'), |
|
486 | + 'desc' => __('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
487 | 487 | 'id' => 'disable_forms_singular', |
488 | 488 | 'type' => 'checkbox' |
489 | 489 | ), |
490 | 490 | array( |
491 | - 'name' => __( 'Disable Form Archives', 'give' ), |
|
492 | - 'desc' => __( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ), |
|
491 | + 'name' => __('Disable Form Archives', 'give'), |
|
492 | + 'desc' => __('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'), |
|
493 | 493 | 'id' => 'disable_forms_archives', |
494 | 494 | 'type' => 'checkbox' |
495 | 495 | ), |
496 | 496 | array( |
497 | - 'name' => __( 'Disable Form Excerpts', 'give' ), |
|
498 | - 'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ), |
|
497 | + 'name' => __('Disable Form Excerpts', 'give'), |
|
498 | + 'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'), |
|
499 | 499 | 'id' => 'disable_forms_excerpt', |
500 | 500 | 'type' => 'checkbox' |
501 | 501 | ), |
502 | 502 | |
503 | 503 | array( |
504 | - 'name' => __( 'Featured Image Size', 'give' ), |
|
505 | - 'desc' => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give' ), |
|
504 | + 'name' => __('Featured Image Size', 'give'), |
|
505 | + 'desc' => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give'), |
|
506 | 506 | 'id' => 'featured_image_size', |
507 | 507 | 'type' => 'select', |
508 | 508 | 'default' => 'large', |
509 | 509 | 'options' => give_get_featured_image_sizes() |
510 | 510 | ), |
511 | 511 | array( |
512 | - 'name' => __( 'Disable Form Featured Image', 'give' ), |
|
513 | - 'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ), |
|
512 | + 'name' => __('Disable Form Featured Image', 'give'), |
|
513 | + 'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'), |
|
514 | 514 | 'id' => 'disable_form_featured_img', |
515 | 515 | 'type' => 'checkbox' |
516 | 516 | ), |
517 | 517 | array( |
518 | - 'name' => __( 'Disable Single Form Sidebar', 'give' ), |
|
519 | - 'desc' => __( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
518 | + 'name' => __('Disable Single Form Sidebar', 'give'), |
|
519 | + 'desc' => __('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
520 | 520 | 'id' => 'disable_form_sidebar', |
521 | 521 | 'type' => 'checkbox' |
522 | 522 | ), |
523 | 523 | array( |
524 | - 'name' => __( 'Taxonomies', 'give' ), |
|
524 | + 'name' => __('Taxonomies', 'give'), |
|
525 | 525 | 'desc' => '', |
526 | 526 | 'id' => 'give_title_display_settings_3', |
527 | 527 | 'type' => 'give_title' |
528 | 528 | ), |
529 | 529 | array( |
530 | - 'name' => __( 'Enable Form Categories', 'give' ), |
|
531 | - 'desc' => __( 'Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give' ), |
|
530 | + 'name' => __('Enable Form Categories', 'give'), |
|
531 | + 'desc' => __('Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give'), |
|
532 | 532 | 'id' => 'enable_categories', |
533 | 533 | 'type' => 'checkbox' |
534 | 534 | ), |
535 | 535 | array( |
536 | - 'name' => __( 'Enable Form Tags', 'give' ), |
|
537 | - 'desc' => __( 'Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give' ), |
|
536 | + 'name' => __('Enable Form Tags', 'give'), |
|
537 | + 'desc' => __('Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give'), |
|
538 | 538 | 'id' => 'enable_tags', |
539 | 539 | 'type' => 'checkbox' |
540 | 540 | ), |
@@ -547,93 +547,93 @@ discard block |
||
547 | 547 | */ |
548 | 548 | 'emails' => array( |
549 | 549 | 'id' => 'email_settings', |
550 | - 'give_title' => __( 'Email Settings', 'give' ), |
|
551 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
552 | - 'fields' => apply_filters( 'give_settings_emails', array( |
|
550 | + 'give_title' => __('Email Settings', 'give'), |
|
551 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
552 | + 'fields' => apply_filters('give_settings_emails', array( |
|
553 | 553 | array( |
554 | - 'name' => __( 'Email Settings', 'give' ), |
|
554 | + 'name' => __('Email Settings', 'give'), |
|
555 | 555 | 'desc' => '', |
556 | 556 | 'id' => 'give_title_email_settings_1', |
557 | 557 | 'type' => 'give_title' |
558 | 558 | ), |
559 | 559 | array( |
560 | 560 | 'id' => 'email_template', |
561 | - 'name' => __( 'Email Template', 'give' ), |
|
562 | - 'desc' => __( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ), |
|
561 | + 'name' => __('Email Template', 'give'), |
|
562 | + 'desc' => __('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'), |
|
563 | 563 | 'type' => 'select', |
564 | 564 | 'options' => give_get_email_templates() |
565 | 565 | ), |
566 | 566 | array( |
567 | 567 | 'id' => 'email_logo', |
568 | - 'name' => __( 'Logo', 'give' ), |
|
569 | - 'desc' => __( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
568 | + 'name' => __('Logo', 'give'), |
|
569 | + 'desc' => __('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
570 | 570 | 'type' => 'file' |
571 | 571 | ), |
572 | 572 | array( |
573 | 573 | 'id' => 'from_name', |
574 | - 'name' => __( 'From Name', 'give' ), |
|
575 | - 'desc' => __( 'The name donation receipts are said to come from. This should probably be your site or shop name.', 'give' ), |
|
576 | - 'default' => get_bloginfo( 'name' ), |
|
574 | + 'name' => __('From Name', 'give'), |
|
575 | + 'desc' => __('The name donation receipts are said to come from. This should probably be your site or shop name.', 'give'), |
|
576 | + 'default' => get_bloginfo('name'), |
|
577 | 577 | 'type' => 'text' |
578 | 578 | ), |
579 | 579 | array( |
580 | 580 | 'id' => 'from_email', |
581 | - 'name' => __( 'From Email', 'give' ), |
|
582 | - 'desc' => __( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ), |
|
583 | - 'default' => get_bloginfo( 'admin_email' ), |
|
581 | + 'name' => __('From Email', 'give'), |
|
582 | + 'desc' => __('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'), |
|
583 | + 'default' => get_bloginfo('admin_email'), |
|
584 | 584 | 'type' => 'text' |
585 | 585 | ), |
586 | 586 | array( |
587 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
587 | + 'name' => __('Donation Receipt', 'give'), |
|
588 | 588 | 'desc' => '', |
589 | 589 | 'id' => 'give_title_email_settings_2', |
590 | 590 | 'type' => 'give_title' |
591 | 591 | ), |
592 | 592 | array( |
593 | 593 | 'id' => 'donation_subject', |
594 | - 'name' => __( 'Donation Email Subject', 'give' ), |
|
595 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
596 | - 'default' => __( 'Donation Receipt', 'give' ), |
|
594 | + 'name' => __('Donation Email Subject', 'give'), |
|
595 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
596 | + 'default' => __('Donation Receipt', 'give'), |
|
597 | 597 | 'type' => 'text' |
598 | 598 | ), |
599 | 599 | array( |
600 | 600 | 'id' => 'donation_receipt', |
601 | - 'name' => __( 'Donation Receipt', 'give' ), |
|
602 | - 'desc' => __( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(), |
|
601 | + 'name' => __('Donation Receipt', 'give'), |
|
602 | + 'desc' => __('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(), |
|
603 | 603 | 'type' => 'wysiwyg', |
604 | 604 | 'default' => give_get_default_donation_receipt_email() |
605 | 605 | ), |
606 | 606 | array( |
607 | - 'name' => __( 'New Donation Notification', 'give' ), |
|
607 | + 'name' => __('New Donation Notification', 'give'), |
|
608 | 608 | 'desc' => '', |
609 | 609 | 'id' => 'give_title_email_settings_3', |
610 | 610 | 'type' => 'give_title' |
611 | 611 | ), |
612 | 612 | array( |
613 | 613 | 'id' => 'donation_notification_subject', |
614 | - 'name' => __( 'Donation Notification Subject', 'give' ), |
|
615 | - 'desc' => __( 'Enter the subject line for the donation notification email.', 'give' ), |
|
614 | + 'name' => __('Donation Notification Subject', 'give'), |
|
615 | + 'desc' => __('Enter the subject line for the donation notification email.', 'give'), |
|
616 | 616 | 'type' => 'text', |
617 | - 'default' => __( 'New Donation - #{payment_id}', 'give' ) |
|
617 | + 'default' => __('New Donation - #{payment_id}', 'give') |
|
618 | 618 | ), |
619 | 619 | array( |
620 | 620 | 'id' => 'donation_notification', |
621 | - 'name' => __( 'Donation Notification', 'give' ), |
|
622 | - 'desc' => __( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(), |
|
621 | + 'name' => __('Donation Notification', 'give'), |
|
622 | + 'desc' => __('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(), |
|
623 | 623 | 'type' => 'wysiwyg', |
624 | 624 | 'default' => give_get_default_donation_notification_email() |
625 | 625 | ), |
626 | 626 | array( |
627 | 627 | 'id' => 'admin_notice_emails', |
628 | - 'name' => __( 'Donation Notification Emails', 'give' ), |
|
629 | - 'desc' => sprintf( __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give' ), '<span class="give-underline">', '</span>' ), |
|
628 | + 'name' => __('Donation Notification Emails', 'give'), |
|
629 | + 'desc' => sprintf(__('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give'), '<span class="give-underline">', '</span>'), |
|
630 | 630 | 'type' => 'textarea', |
631 | - 'default' => get_bloginfo( 'admin_email' ) |
|
631 | + 'default' => get_bloginfo('admin_email') |
|
632 | 632 | ), |
633 | 633 | array( |
634 | 634 | 'id' => 'disable_admin_notices', |
635 | - 'name' => __( 'Disable Admin Notifications', 'give' ), |
|
636 | - 'desc' => __( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ), |
|
635 | + 'name' => __('Disable Admin Notifications', 'give'), |
|
636 | + 'desc' => __('Check this box if you do not want to receive emails when new donations are made.', 'give'), |
|
637 | 637 | 'type' => 'checkbox' |
638 | 638 | ) |
639 | 639 | ) |
@@ -642,96 +642,96 @@ discard block |
||
642 | 642 | /** Extension Settings */ |
643 | 643 | 'addons' => array( |
644 | 644 | 'id' => 'addons', |
645 | - 'give_title' => __( 'Give Add-ons Settings', 'give' ), |
|
646 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
647 | - 'fields' => apply_filters( 'give_settings_addons', array() |
|
645 | + 'give_title' => __('Give Add-ons Settings', 'give'), |
|
646 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
647 | + 'fields' => apply_filters('give_settings_addons', array() |
|
648 | 648 | ) |
649 | 649 | ), |
650 | 650 | /** Licenses Settings */ |
651 | 651 | 'licenses' => array( |
652 | 652 | 'id' => 'licenses', |
653 | - 'give_title' => __( 'Give Licenses', 'give' ), |
|
654 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
655 | - 'fields' => apply_filters( 'give_settings_licenses', array() |
|
653 | + 'give_title' => __('Give Licenses', 'give'), |
|
654 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
655 | + 'fields' => apply_filters('give_settings_licenses', array() |
|
656 | 656 | ) |
657 | 657 | ), |
658 | 658 | /** Advanced Options */ |
659 | 659 | 'advanced' => array( |
660 | 660 | 'id' => 'advanced_options', |
661 | - 'give_title' => __( 'Advanced Options', 'give' ), |
|
662 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
663 | - 'fields' => apply_filters( 'give_settings_advanced', array( |
|
661 | + 'give_title' => __('Advanced Options', 'give'), |
|
662 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
663 | + 'fields' => apply_filters('give_settings_advanced', array( |
|
664 | 664 | array( |
665 | - 'name' => __( 'Access Control', 'give' ), |
|
665 | + 'name' => __('Access Control', 'give'), |
|
666 | 666 | 'desc' => '', |
667 | 667 | 'id' => 'give_title_session_control_1', |
668 | 668 | 'type' => 'give_title' |
669 | 669 | ), |
670 | 670 | array( |
671 | 671 | 'id' => 'session_lifetime', |
672 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
673 | - 'desc' => __( 'Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give' ), |
|
672 | + 'name' => __('Session Lifetime', 'give'), |
|
673 | + 'desc' => __('Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give'), |
|
674 | 674 | 'type' => 'select', |
675 | 675 | 'options' => array( |
676 | - '86400' => __( '24 Hours', 'give' ), |
|
677 | - '172800' => __( '48 Hours', 'give' ), |
|
678 | - '259200' => __( '72 Hours', 'give' ), |
|
679 | - '604800' => __( '1 Week', 'give' ), |
|
676 | + '86400' => __('24 Hours', 'give'), |
|
677 | + '172800' => __('48 Hours', 'give'), |
|
678 | + '259200' => __('72 Hours', 'give'), |
|
679 | + '604800' => __('1 Week', 'give'), |
|
680 | 680 | ) |
681 | 681 | ), |
682 | 682 | array( |
683 | - 'name' => __( 'Email Access', 'give' ), |
|
684 | - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
683 | + 'name' => __('Email Access', 'give'), |
|
684 | + 'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
685 | 685 | 'id' => 'email_access', |
686 | 686 | 'type' => 'checkbox', |
687 | 687 | ), |
688 | 688 | array( |
689 | 689 | 'id' => 'recaptcha_key', |
690 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
691 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>' ), |
|
690 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
691 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>'), |
|
692 | 692 | 'default' => '', |
693 | 693 | 'type' => 'text' |
694 | 694 | ), |
695 | 695 | array( |
696 | 696 | 'id' => 'recaptcha_secret', |
697 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
698 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ), |
|
697 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
698 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'), |
|
699 | 699 | 'default' => '', |
700 | 700 | 'type' => 'text' |
701 | 701 | ), |
702 | 702 | array( |
703 | - 'name' => __( 'Data Control', 'give' ), |
|
703 | + 'name' => __('Data Control', 'give'), |
|
704 | 704 | 'desc' => '', |
705 | 705 | 'id' => 'give_title_data_control_2', |
706 | 706 | 'type' => 'give_title' |
707 | 707 | ), |
708 | 708 | array( |
709 | - 'name' => __( 'Remove All Data on Uninstall?', 'give' ), |
|
710 | - 'desc' => __( 'Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give' ), |
|
709 | + 'name' => __('Remove All Data on Uninstall?', 'give'), |
|
710 | + 'desc' => __('Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give'), |
|
711 | 711 | 'id' => 'uninstall_on_delete', |
712 | 712 | 'type' => 'checkbox' |
713 | 713 | ), |
714 | 714 | array( |
715 | - 'name' => __( 'Filter Control', 'give' ), |
|
715 | + 'name' => __('Filter Control', 'give'), |
|
716 | 716 | 'desc' => '', |
717 | 717 | 'id' => 'give_title_filter_control', |
718 | 718 | 'type' => 'give_title' |
719 | 719 | ), |
720 | 720 | array( |
721 | - 'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ), |
|
722 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
721 | + 'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'), |
|
722 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
723 | 723 | 'id' => 'disable_the_content_filter', |
724 | 724 | 'type' => 'checkbox' |
725 | 725 | ), |
726 | 726 | array( |
727 | - 'name' => __( 'Script Loading', 'give' ), |
|
727 | + 'name' => __('Script Loading', 'give'), |
|
728 | 728 | 'desc' => '', |
729 | 729 | 'id' => 'give_title_script_control', |
730 | 730 | 'type' => 'give_title' |
731 | 731 | ), |
732 | 732 | array( |
733 | - 'name' => __( 'Load Scripts in Footer?', 'give' ), |
|
734 | - 'desc' => __( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ), |
|
733 | + 'name' => __('Load Scripts in Footer?', 'give'), |
|
734 | + 'desc' => __('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'), |
|
735 | 735 | 'id' => 'scripts_footer', |
736 | 736 | 'type' => 'checkbox' |
737 | 737 | ) |
@@ -741,13 +741,13 @@ discard block |
||
741 | 741 | /** API Settings */ |
742 | 742 | 'api' => array( |
743 | 743 | 'id' => 'api', |
744 | - 'give_title' => __( 'API', 'give' ), |
|
745 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
744 | + 'give_title' => __('API', 'give'), |
|
745 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
746 | 746 | 'show_names' => false, // Hide field names on the left |
747 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
747 | + 'fields' => apply_filters('give_settings_system', array( |
|
748 | 748 | array( |
749 | 749 | 'id' => 'api', |
750 | - 'name' => __( 'API', 'give' ), |
|
750 | + 'name' => __('API', 'give'), |
|
751 | 751 | 'type' => 'api' |
752 | 752 | ) |
753 | 753 | ) |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | /** Licenses Settings */ |
757 | 757 | 'system_info' => array( |
758 | 758 | 'id' => 'system_info', |
759 | - 'give_title' => __( 'System Info', 'give' ), |
|
760 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
761 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
759 | + 'give_title' => __('System Info', 'give'), |
|
760 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
761 | + 'fields' => apply_filters('give_settings_system', array( |
|
762 | 762 | array( |
763 | 763 | 'id' => 'system_info', |
764 | - 'name' => __( 'System Info', 'give' ), |
|
765 | - 'desc' => __( 'Please copy and paste this information in your ticket when contacting support.', 'give' ), |
|
764 | + 'name' => __('System Info', 'give'), |
|
765 | + 'desc' => __('Please copy and paste this information in your ticket when contacting support.', 'give'), |
|
766 | 766 | 'type' => 'system_info' |
767 | 767 | ) |
768 | 768 | ) |
@@ -771,15 +771,15 @@ discard block |
||
771 | 771 | ); |
772 | 772 | |
773 | 773 | //Return all settings array if no active tab |
774 | - if ( $active_tab === null || ! isset( $give_settings[ $active_tab ] ) ) { |
|
774 | + if ($active_tab === null || ! isset($give_settings[$active_tab])) { |
|
775 | 775 | |
776 | - return apply_filters( 'give_registered_settings', $give_settings ); |
|
776 | + return apply_filters('give_registered_settings', $give_settings); |
|
777 | 777 | |
778 | 778 | } |
779 | 779 | |
780 | 780 | |
781 | 781 | // Add other tabs and settings fields as needed |
782 | - return apply_filters( 'give_registered_settings', $give_settings[ $active_tab ] ); |
|
782 | + return apply_filters('give_registered_settings', $give_settings[$active_tab]); |
|
783 | 783 | |
784 | 784 | } |
785 | 785 | |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | */ |
789 | 789 | public function settings_notices() { |
790 | 790 | |
791 | - if ( ! isset( $_POST['give_settings_saved'] ) ) { |
|
791 | + if ( ! isset($_POST['give_settings_saved'])) { |
|
792 | 792 | return; |
793 | 793 | } |
794 | 794 | |
795 | - add_settings_error( 'give-notices', 'global-settings-updated', __( 'Settings updated.', 'give' ), 'updated' ); |
|
795 | + add_settings_error('give-notices', 'global-settings-updated', __('Settings updated.', 'give'), 'updated'); |
|
796 | 796 | |
797 | 797 | } |
798 | 798 | |
@@ -806,17 +806,17 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return mixed Field value or exception is thrown |
808 | 808 | */ |
809 | - public function __get( $field ) { |
|
809 | + public function __get($field) { |
|
810 | 810 | |
811 | 811 | // Allowed fields to retrieve |
812 | - if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) { |
|
812 | + if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) { |
|
813 | 813 | return $this->{$field}; |
814 | 814 | } |
815 | - if ( 'option_metabox' === $field ) { |
|
815 | + if ('option_metabox' === $field) { |
|
816 | 816 | return $this->option_metabox(); |
817 | 817 | } |
818 | 818 | |
819 | - throw new Exception( 'Invalid property: ' . $field ); |
|
819 | + throw new Exception('Invalid property: '.$field); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | |
@@ -833,12 +833,12 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @return mixed Option value |
835 | 835 | */ |
836 | -function give_get_option( $key = '', $default = false ) { |
|
836 | +function give_get_option($key = '', $default = false) { |
|
837 | 837 | global $give_options; |
838 | - $value = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default; |
|
839 | - $value = apply_filters( 'give_get_option', $value, $key, $default ); |
|
838 | + $value = ! empty($give_options[$key]) ? $give_options[$key] : $default; |
|
839 | + $value = apply_filters('give_get_option', $value, $key, $default); |
|
840 | 840 | |
841 | - return apply_filters( 'give_get_option_' . $key, $value, $key, $default ); |
|
841 | + return apply_filters('give_get_option_'.$key, $value, $key, $default); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | |
@@ -856,33 +856,33 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return boolean True if updated, false if not. |
858 | 858 | */ |
859 | -function give_update_option( $key = '', $value = false ) { |
|
859 | +function give_update_option($key = '', $value = false) { |
|
860 | 860 | |
861 | 861 | // If no key, exit |
862 | - if ( empty( $key ) ) { |
|
862 | + if (empty($key)) { |
|
863 | 863 | return false; |
864 | 864 | } |
865 | 865 | |
866 | - if ( empty( $value ) ) { |
|
867 | - $remove_option = give_delete_option( $key ); |
|
866 | + if (empty($value)) { |
|
867 | + $remove_option = give_delete_option($key); |
|
868 | 868 | |
869 | 869 | return $remove_option; |
870 | 870 | } |
871 | 871 | |
872 | 872 | // First let's grab the current settings |
873 | - $options = get_option( 'give_settings' ); |
|
873 | + $options = get_option('give_settings'); |
|
874 | 874 | |
875 | 875 | // Let's let devs alter that value coming in |
876 | - $value = apply_filters( 'give_update_option', $value, $key ); |
|
876 | + $value = apply_filters('give_update_option', $value, $key); |
|
877 | 877 | |
878 | 878 | // Next let's try to update the value |
879 | - $options[ $key ] = $value; |
|
880 | - $did_update = update_option( 'give_settings', $options ); |
|
879 | + $options[$key] = $value; |
|
880 | + $did_update = update_option('give_settings', $options); |
|
881 | 881 | |
882 | 882 | // If it updated, let's update the global variable |
883 | - if ( $did_update ) { |
|
883 | + if ($did_update) { |
|
884 | 884 | global $give_options; |
885 | - $give_options[ $key ] = $value; |
|
885 | + $give_options[$key] = $value; |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | return $did_update; |
@@ -899,27 +899,27 @@ discard block |
||
899 | 899 | * |
900 | 900 | * @return boolean True if updated, false if not. |
901 | 901 | */ |
902 | -function give_delete_option( $key = '' ) { |
|
902 | +function give_delete_option($key = '') { |
|
903 | 903 | |
904 | 904 | // If no key, exit |
905 | - if ( empty( $key ) ) { |
|
905 | + if (empty($key)) { |
|
906 | 906 | return false; |
907 | 907 | } |
908 | 908 | |
909 | 909 | // First let's grab the current settings |
910 | - $options = get_option( 'give_settings' ); |
|
910 | + $options = get_option('give_settings'); |
|
911 | 911 | |
912 | 912 | // Next let's try to update the value |
913 | - if ( isset( $options[ $key ] ) ) { |
|
913 | + if (isset($options[$key])) { |
|
914 | 914 | |
915 | - unset( $options[ $key ] ); |
|
915 | + unset($options[$key]); |
|
916 | 916 | |
917 | 917 | } |
918 | 918 | |
919 | - $did_update = update_option( 'give_settings', $options ); |
|
919 | + $did_update = update_option('give_settings', $options); |
|
920 | 920 | |
921 | 921 | // If it updated, let's update the global variable |
922 | - if ( $did_update ) { |
|
922 | + if ($did_update) { |
|
923 | 923 | global $give_options; |
924 | 924 | $give_options = $options; |
925 | 925 | } |
@@ -938,9 +938,9 @@ discard block |
||
938 | 938 | */ |
939 | 939 | function give_get_settings() { |
940 | 940 | |
941 | - $settings = get_option( 'give_settings' ); |
|
941 | + $settings = get_option('give_settings'); |
|
942 | 942 | |
943 | - return (array) apply_filters( 'give_get_settings', $settings ); |
|
943 | + return (array) apply_filters('give_get_settings', $settings); |
|
944 | 944 | |
945 | 945 | } |
946 | 946 | |
@@ -958,25 +958,25 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return array |
960 | 960 | */ |
961 | -function give_settings_array_insert( $array, $position, $insert ) { |
|
962 | - if ( is_int( $position ) ) { |
|
963 | - array_splice( $array, $position, 0, $insert ); |
|
961 | +function give_settings_array_insert($array, $position, $insert) { |
|
962 | + if (is_int($position)) { |
|
963 | + array_splice($array, $position, 0, $insert); |
|
964 | 964 | } else { |
965 | 965 | |
966 | - foreach ( $array as $index => $subarray ) { |
|
967 | - if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) { |
|
966 | + foreach ($array as $index => $subarray) { |
|
967 | + if (isset($subarray['id']) && $subarray['id'] == $position) { |
|
968 | 968 | $pos = $index; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
972 | - if ( ! isset( $pos ) ) { |
|
972 | + if ( ! isset($pos)) { |
|
973 | 973 | return $array; |
974 | 974 | } |
975 | 975 | |
976 | 976 | $array = array_merge( |
977 | - array_slice( $array, 0, $pos ), |
|
977 | + array_slice($array, 0, $pos), |
|
978 | 978 | $insert, |
979 | - array_slice( $array, $pos ) |
|
979 | + array_slice($array, $pos) |
|
980 | 980 | ); |
981 | 981 | } |
982 | 982 | |
@@ -999,31 +999,31 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return void |
1001 | 1001 | */ |
1002 | -function give_enabled_gateways_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1002 | +function give_enabled_gateways_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1003 | 1003 | |
1004 | 1004 | $id = $field_type_object->field->args['id']; |
1005 | 1005 | $field_description = $field_type_object->field->args['desc']; |
1006 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
1006 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
1007 | 1007 | |
1008 | 1008 | echo '<ul class="cmb2-checkbox-list cmb2-list">'; |
1009 | 1009 | |
1010 | - foreach ( $gateways as $key => $option ) : |
|
1010 | + foreach ($gateways as $key => $option) : |
|
1011 | 1011 | |
1012 | - if ( is_array( $escaped_value ) && array_key_exists( $key, $escaped_value ) ) { |
|
1012 | + if (is_array($escaped_value) && array_key_exists($key, $escaped_value)) { |
|
1013 | 1013 | $enabled = '1'; |
1014 | 1014 | } else { |
1015 | 1015 | $enabled = null; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/> '; |
|
1019 | - echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>'; |
|
1018 | + echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/> '; |
|
1019 | + echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>'; |
|
1020 | 1020 | |
1021 | 1021 | endforeach; |
1022 | 1022 | |
1023 | 1023 | echo '</ul>'; |
1024 | 1024 | |
1025 | - if ( $field_description ) { |
|
1026 | - echo '<p class="cmb2-metabox-description">' . $field_description . '</p>'; |
|
1025 | + if ($field_description) { |
|
1026 | + echo '<p class="cmb2-metabox-description">'.$field_description.'</p>'; |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | } |
@@ -1039,31 +1039,31 @@ discard block |
||
1039 | 1039 | * |
1040 | 1040 | * @return void |
1041 | 1041 | */ |
1042 | -function give_default_gateway_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1042 | +function give_default_gateway_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1043 | 1043 | |
1044 | 1044 | $id = $field_type_object->field->args['id']; |
1045 | 1045 | $field_description = $field_type_object->field->args['desc']; |
1046 | 1046 | $gateways = give_get_enabled_payment_gateways(); |
1047 | 1047 | |
1048 | - echo '<select class="cmb2_select" name="' . $id . '" id="' . $id . '">'; |
|
1048 | + echo '<select class="cmb2_select" name="'.$id.'" id="'.$id.'">'; |
|
1049 | 1049 | |
1050 | 1050 | //Add a field to the Give Form admin single post view of this field |
1051 | - if ( $field_type_object->field->object_type === 'post' ) { |
|
1052 | - echo '<option value="global">' . __( 'Global Default', 'give' ) . '</option>'; |
|
1051 | + if ($field_type_object->field->object_type === 'post') { |
|
1052 | + echo '<option value="global">'.__('Global Default', 'give').'</option>'; |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | - foreach ( $gateways as $key => $option ) : |
|
1055 | + foreach ($gateways as $key => $option) : |
|
1056 | 1056 | |
1057 | - $selected = isset( $escaped_value ) ? selected( $key, $escaped_value, false ) : ''; |
|
1057 | + $selected = isset($escaped_value) ? selected($key, $escaped_value, false) : ''; |
|
1058 | 1058 | |
1059 | 1059 | |
1060 | - echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1060 | + echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>'; |
|
1061 | 1061 | |
1062 | 1062 | endforeach; |
1063 | 1063 | |
1064 | 1064 | echo '</select>'; |
1065 | 1065 | |
1066 | - echo '<p class="cmb2-metabox-description">' . $field_description . '</p>'; |
|
1066 | + echo '<p class="cmb2-metabox-description">'.$field_description.'</p>'; |
|
1067 | 1067 | |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1078,13 +1078,13 @@ discard block |
||
1078 | 1078 | * |
1079 | 1079 | * @return void |
1080 | 1080 | */ |
1081 | -function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1081 | +function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1082 | 1082 | |
1083 | 1083 | $id = $field_type_object->field->args['id']; |
1084 | 1084 | $title = $field_type_object->field->args['name']; |
1085 | 1085 | $field_description = $field_type_object->field->args['desc']; |
1086 | 1086 | |
1087 | - echo '<hr>' . $field_description; |
|
1087 | + echo '<hr>'.$field_description; |
|
1088 | 1088 | |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | * |
1100 | 1100 | * @return void |
1101 | 1101 | */ |
1102 | -function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1102 | +function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1103 | 1103 | |
1104 | 1104 | $id = $field_type_object->field->args['id']; |
1105 | 1105 | $title = $field_type_object->field->args['name']; |
@@ -1119,25 +1119,25 @@ discard block |
||
1119 | 1119 | * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types |
1120 | 1120 | * @return array An array of options that matches the CMB2 options array |
1121 | 1121 | */ |
1122 | -function give_cmb2_get_post_options( $query_args, $force = false ) { |
|
1122 | +function give_cmb2_get_post_options($query_args, $force = false) { |
|
1123 | 1123 | |
1124 | - $post_options = array( '' => '' ); // Blank option |
|
1124 | + $post_options = array('' => ''); // Blank option |
|
1125 | 1125 | |
1126 | - if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) { |
|
1126 | + if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) { |
|
1127 | 1127 | return $post_options; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - $args = wp_parse_args( $query_args, array( |
|
1130 | + $args = wp_parse_args($query_args, array( |
|
1131 | 1131 | 'post_type' => 'page', |
1132 | 1132 | 'numberposts' => 10, |
1133 | - ) ); |
|
1133 | + )); |
|
1134 | 1134 | |
1135 | - $posts = get_posts( $args ); |
|
1135 | + $posts = get_posts($args); |
|
1136 | 1136 | |
1137 | - if ( $posts ) { |
|
1138 | - foreach ( $posts as $post ) { |
|
1137 | + if ($posts) { |
|
1138 | + foreach ($posts as $post) { |
|
1139 | 1139 | |
1140 | - $post_options[ $post->ID ] = $post->post_title; |
|
1140 | + $post_options[$post->ID] = $post->post_title; |
|
1141 | 1141 | |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1157,17 +1157,17 @@ discard block |
||
1157 | 1157 | global $_wp_additional_image_sizes; |
1158 | 1158 | $sizes = array(); |
1159 | 1159 | |
1160 | - foreach ( get_intermediate_image_sizes() as $_size ) { |
|
1160 | + foreach (get_intermediate_image_sizes() as $_size) { |
|
1161 | 1161 | |
1162 | - if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { |
|
1163 | - $sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" ); |
|
1164 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
1165 | - $sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height']; |
|
1162 | + if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) { |
|
1163 | + $sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h"); |
|
1164 | + } elseif (isset($_wp_additional_image_sizes[$_size])) { |
|
1165 | + $sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height']; |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | } |
1169 | 1169 | |
1170 | - return apply_filters( 'give_get_featured_image_sizes', $sizes ); |
|
1170 | + return apply_filters('give_get_featured_image_sizes', $sizes); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | |
@@ -1181,34 +1181,34 @@ discard block |
||
1181 | 1181 | * |
1182 | 1182 | * @return void |
1183 | 1183 | */ |
1184 | -function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1184 | +function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1185 | 1185 | |
1186 | 1186 | $id = $field_type_object->field->args['id']; |
1187 | 1187 | $field_description = $field_type_object->field->args['desc']; |
1188 | - $license_status = get_option( $field_type_object->field->args['options']['is_valid_license_option'] ); |
|
1188 | + $license_status = get_option($field_type_object->field->args['options']['is_valid_license_option']); |
|
1189 | 1189 | $field_classes = 'regular-text give-license-field'; |
1190 | - $type = empty( $escaped_value ) ? 'text' : 'password'; |
|
1190 | + $type = empty($escaped_value) ? 'text' : 'password'; |
|
1191 | 1191 | |
1192 | - if ( $license_status === 'valid' ) { |
|
1192 | + if ($license_status === 'valid') { |
|
1193 | 1193 | $field_classes .= ' give-license-active'; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $html = $field_type_object->input( array( |
|
1196 | + $html = $field_type_object->input(array( |
|
1197 | 1197 | 'class' => $field_classes, |
1198 | 1198 | 'type' => $type |
1199 | - ) ); |
|
1199 | + )); |
|
1200 | 1200 | |
1201 | 1201 | //License is active so show deactivate button |
1202 | - if ( $license_status === 'valid' ) { |
|
1203 | - $html .= '<input type="submit" class="button-secondary give-license-deactivate" name="' . $id . '_deactivate" value="' . __( 'Deactivate License', 'give' ) . '"/>'; |
|
1202 | + if ($license_status === 'valid') { |
|
1203 | + $html .= '<input type="submit" class="button-secondary give-license-deactivate" name="'.$id.'_deactivate" value="'.__('Deactivate License', 'give').'"/>'; |
|
1204 | 1204 | } else { |
1205 | 1205 | //This license is not valid so delete it |
1206 | - give_delete_option( $id ); |
|
1206 | + give_delete_option($id); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | - $html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>'; |
|
1209 | + $html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>'; |
|
1210 | 1210 | |
1211 | - wp_nonce_field( $id . '-nonce', $id . '-nonce' ); |
|
1211 | + wp_nonce_field($id.'-nonce', $id.'-nonce'); |
|
1212 | 1212 | |
1213 | 1213 | echo $html; |
1214 | 1214 | } |
@@ -1222,13 +1222,13 @@ discard block |
||
1222 | 1222 | */ |
1223 | 1223 | function give_api_callback() { |
1224 | 1224 | |
1225 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1225 | + if ( ! current_user_can('manage_give_settings')) { |
|
1226 | 1226 | return; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - do_action( 'give_tools_api_keys_before' ); |
|
1229 | + do_action('give_tools_api_keys_before'); |
|
1230 | 1230 | |
1231 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
1231 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
1232 | 1232 | |
1233 | 1233 | $api_keys_table = new Give_API_Keys_Table(); |
1234 | 1234 | $api_keys_table->prepare_items(); |
@@ -1236,17 +1236,17 @@ discard block |
||
1236 | 1236 | ?> |
1237 | 1237 | <span class="cmb2-metabox-description api-description"> |
1238 | 1238 | <?php echo sprintf( |
1239 | - __( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ), |
|
1240 | - esc_url( 'https://givewp.com/documentation/give-api-reference/' ), |
|
1241 | - esc_url( 'https://givewp.com/addons/zapier/' ) |
|
1239 | + __('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'), |
|
1240 | + esc_url('https://givewp.com/documentation/give-api-reference/'), |
|
1241 | + esc_url('https://givewp.com/addons/zapier/') |
|
1242 | 1242 | ); ?> |
1243 | 1243 | </span> |
1244 | 1244 | <?php |
1245 | 1245 | |
1246 | - do_action( 'give_tools_api_keys_after' ); |
|
1246 | + do_action('give_tools_api_keys_after'); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | -add_action( 'give_settings_tab_api_keys', 'give_api_callback' ); |
|
1249 | +add_action('give_settings_tab_api_keys', 'give_api_callback'); |
|
1250 | 1250 | |
1251 | 1251 | /** |
1252 | 1252 | * Hook Callback |
@@ -1259,8 +1259,8 @@ discard block |
||
1259 | 1259 | * |
1260 | 1260 | * @return void |
1261 | 1261 | */ |
1262 | -function give_hook_callback( $args ) { |
|
1263 | - do_action( 'give_' . $args['id'] ); |
|
1262 | +function give_hook_callback($args) { |
|
1263 | + do_action('give_'.$args['id']); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | /** |
@@ -1270,10 +1270,10 @@ discard block |
||
1270 | 1270 | * |
1271 | 1271 | */ |
1272 | 1272 | |
1273 | -if ( file_exists( WP_PLUGIN_DIR . '/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1274 | - require_once WP_PLUGIN_DIR . '/cmb2/init.php'; |
|
1275 | -} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1276 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php'; |
|
1277 | -} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) { |
|
1278 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php'; |
|
1273 | +if (file_exists(WP_PLUGIN_DIR.'/cmb2/init.php') && ! defined('CMB2_LOADED')) { |
|
1274 | + require_once WP_PLUGIN_DIR.'/cmb2/init.php'; |
|
1275 | +} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php') && ! defined('CMB2_LOADED')) { |
|
1276 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php'; |
|
1277 | +} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php') && ! defined('CMB2_LOADED')) { |
|
1278 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php'; |
|
1279 | 1279 | } |
1280 | 1280 | \ No newline at end of file |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php'; |
|
19 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php'; |
|
18 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php'; |
|
19 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Process batch exports via ajax |
@@ -26,79 +26,79 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_do_ajax_export() { |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | - parse_str( $_POST['form'], $form ); |
|
31 | + parse_str($_POST['form'], $form); |
|
32 | 32 | |
33 | 33 | $_REQUEST = $form = (array) $form; |
34 | 34 | |
35 | - if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) { |
|
36 | - die( '-2' ); |
|
35 | + if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) { |
|
36 | + die('-2'); |
|
37 | 37 | } |
38 | 38 | |
39 | - do_action( 'give_batch_export_class_include', $form['give-export-class'] ); |
|
39 | + do_action('give_batch_export_class_include', $form['give-export-class']); |
|
40 | 40 | |
41 | - $step = absint( $_POST['step'] ); |
|
42 | - $class = sanitize_text_field( $form['give-export-class'] ); |
|
41 | + $step = absint($_POST['step']); |
|
42 | + $class = sanitize_text_field($form['give-export-class']); |
|
43 | 43 | |
44 | - $export = new $class( $step ); |
|
44 | + $export = new $class($step); |
|
45 | 45 | |
46 | - if ( ! $export->can_export() ) { |
|
47 | - die( '-1' ); |
|
46 | + if ( ! $export->can_export()) { |
|
47 | + die('-1'); |
|
48 | 48 | } |
49 | 49 | |
50 | - if ( ! $export->is_writable ) { |
|
50 | + if ( ! $export->is_writable) { |
|
51 | 51 | $json_args = array( |
52 | 52 | 'error' => true, |
53 | - 'message' => __( 'Export location or file not writable.', 'give' ) |
|
53 | + 'message' => __('Export location or file not writable.', 'give') |
|
54 | 54 | ); |
55 | 55 | echo json_encode($json_args); |
56 | 56 | exit; |
57 | 57 | } |
58 | 58 | |
59 | - $export->set_properties( $_REQUEST ); |
|
59 | + $export->set_properties($_REQUEST); |
|
60 | 60 | |
61 | 61 | $export->pre_fetch(); |
62 | 62 | |
63 | - $ret = $export->process_step( $step ); |
|
63 | + $ret = $export->process_step($step); |
|
64 | 64 | |
65 | 65 | $percentage = $export->get_percentage_complete(); |
66 | 66 | |
67 | - if ( $ret ) { |
|
67 | + if ($ret) { |
|
68 | 68 | |
69 | 69 | $step += 1; |
70 | - echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) ); |
|
70 | + echo json_encode(array('step' => $step, 'percentage' => $percentage)); |
|
71 | 71 | exit; |
72 | 72 | |
73 | - } elseif ( true === $export->is_empty ) { |
|
73 | + } elseif (true === $export->is_empty) { |
|
74 | 74 | |
75 | - echo json_encode( array( |
|
75 | + echo json_encode(array( |
|
76 | 76 | 'error' => true, |
77 | - 'message' => __( 'No data found for export parameters.', 'give' ) |
|
78 | - ) ); |
|
77 | + 'message' => __('No data found for export parameters.', 'give') |
|
78 | + )); |
|
79 | 79 | exit; |
80 | 80 | |
81 | - } elseif ( true === $export->done && true === $export->is_void ) { |
|
81 | + } elseif (true === $export->done && true === $export->is_void) { |
|
82 | 82 | |
83 | - $message = ! empty( $export->message ) ? $export->message : __( 'Batch Processing Complete', 'give' ); |
|
84 | - echo json_encode( array( 'success' => true, 'message' => $message ) ); |
|
83 | + $message = ! empty($export->message) ? $export->message : __('Batch Processing Complete', 'give'); |
|
84 | + echo json_encode(array('success' => true, 'message' => $message)); |
|
85 | 85 | exit; |
86 | 86 | |
87 | 87 | } else { |
88 | 88 | |
89 | - $args = array_merge( $_REQUEST, array( |
|
89 | + $args = array_merge($_REQUEST, array( |
|
90 | 90 | 'step' => $step, |
91 | 91 | 'class' => $class, |
92 | - 'nonce' => wp_create_nonce( 'give-batch-export' ), |
|
92 | + 'nonce' => wp_create_nonce('give-batch-export'), |
|
93 | 93 | 'give_action' => 'form_batch_export', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $download_url = add_query_arg( $args, admin_url() ); |
|
96 | + $download_url = add_query_arg($args, admin_url()); |
|
97 | 97 | |
98 | - echo json_encode( array( 'step' => 'done', 'url' => $download_url ) ); |
|
98 | + echo json_encode(array('step' => 'done', 'url' => $download_url)); |
|
99 | 99 | exit; |
100 | 100 | |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' ); |
|
104 | +add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
31 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
32 | 32 | |
33 | 33 | $export = new $_REQUEST['class']; |
34 | 34 | $export->export(); |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
38 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Exports earnings for a specified time period |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | function give_export_earnings() { |
49 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
49 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
50 | 50 | |
51 | 51 | $earnings_export = new Give_Earnings_Export(); |
52 | 52 | |
53 | 53 | $earnings_export->export(); |
54 | 54 | } |
55 | 55 | |
56 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
56 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | function give_export_all_customers() { |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
70 | 70 | |
71 | 71 | $customer_export = new Give_Donors_Export(); |
72 | 72 | |
73 | 73 | $customer_export->export(); |
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
76 | +add_action('give_email_export', 'give_export_all_customers'); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function give_register_batch_exporters() { |
85 | - if ( is_admin() ) { |
|
86 | - do_action( 'give_register_batch_exporter' ); |
|
85 | + if (is_admin()) { |
|
86 | + do_action('give_register_batch_exporter'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
90 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Register the payments batch exporter |
94 | 94 | * @since 1.5 |
95 | 95 | */ |
96 | 96 | function give_register_payments_batch_export() { |
97 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
97 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
98 | 98 | } |
99 | 99 | |
100 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
100 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Loads the payments batch process if needed |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return void |
110 | 110 | */ |
111 | -function give_include_payments_batch_processor( $class ) { |
|
111 | +function give_include_payments_batch_processor($class) { |
|
112 | 112 | |
113 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
114 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
113 | + if ('Give_Batch_Payments_Export' === $class) { |
|
114 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * @since 1.5.2 |
122 | 122 | */ |
123 | 123 | function give_register_customers_batch_export() { |
124 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
124 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
125 | 125 | } |
126 | 126 | |
127 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
127 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Loads the customers batch process if needed |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_include_customers_batch_processor( $class ) { |
|
138 | +function give_include_customers_batch_processor($class) { |
|
139 | 139 | |
140 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
141 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
140 | + if ('Give_Batch_Customers_Export' === $class) { |
|
141 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * @since 1.5 |
150 | 150 | */ |
151 | 151 | function give_register_forms_batch_export() { |
152 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
152 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
155 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Loads the file downloads batch process if needed |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return void |
165 | 165 | */ |
166 | -function give_include_forms_batch_processor( $class ) { |
|
166 | +function give_include_forms_batch_processor($class) { |
|
167 | 167 | |
168 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
169 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
168 | + if ('Give_Batch_Forms_Export' === $class) { |
|
169 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | \ No newline at end of file |
@@ -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 | |
@@ -25,75 +25,75 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
40 | 40 | |
41 | - $daterange = date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ) . ' ' . utf8_decode( __( 'to', 'give' ) ) . ' ' . date_i18n( get_option( 'date_format' ) ); |
|
41 | + $daterange = date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))).' '.utf8_decode(__('to', 'give')).' '.date_i18n(get_option('date_format')); |
|
42 | 42 | |
43 | 43 | $pdf = new give_pdf(); |
44 | - $pdf->AddPage( 'L', 'A4' ); |
|
44 | + $pdf->AddPage('L', 'A4'); |
|
45 | 45 | |
46 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
47 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
48 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
46 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
47 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
48 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
49 | 49 | |
50 | - $pdf->Image( GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png', 247, 8 ); |
|
50 | + $pdf->Image(GIVE_PLUGIN_URL.'assets/images/give-logo-small.png', 247, 8); |
|
51 | 51 | |
52 | - $pdf->SetMargins( 8, 8, 8 ); |
|
53 | - $pdf->SetX( 8 ); |
|
52 | + $pdf->SetMargins(8, 8, 8); |
|
53 | + $pdf->SetX(8); |
|
54 | 54 | |
55 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
56 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
57 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
55 | + $pdf->SetFont('Helvetica', '', 16); |
|
56 | + $pdf->SetTextColor(50, 50, 50); |
|
57 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
58 | 58 | |
59 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
59 | + $pdf->SetFont('Helvetica', '', 13); |
|
60 | 60 | $pdf->Ln(); |
61 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
62 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
61 | + $pdf->SetTextColor(150, 150, 150); |
|
62 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
63 | 63 | $pdf->Ln(); |
64 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
65 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
66 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
67 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
64 | + $pdf->SetTextColor(50, 50, 50); |
|
65 | + $pdf->SetFont('Helvetica', '', 14); |
|
66 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
67 | + $pdf->SetFont('Helvetica', '', 12); |
|
68 | 68 | |
69 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
70 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
71 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
72 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
73 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
74 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
75 | - $pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
69 | + $pdf->SetFillColor(238, 238, 238); |
|
70 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
71 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
72 | + $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
73 | + $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
74 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
75 | + $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
76 | 76 | |
77 | - $year = date( 'Y' ); |
|
78 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
77 | + $year = date('Y'); |
|
78 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
79 | 79 | |
80 | - if ( $give_forms ): |
|
81 | - $pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) ); |
|
80 | + if ($give_forms): |
|
81 | + $pdf->SetWidths(array(70, 30, 50, 50, 45, 35)); |
|
82 | 82 | |
83 | - foreach ( $give_forms as $form ): |
|
84 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
83 | + foreach ($give_forms as $form): |
|
84 | + $pdf->SetFillColor(255, 255, 255); |
|
85 | 85 | |
86 | 86 | $title = $form->post_title; |
87 | 87 | |
88 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
88 | + if (give_has_variable_prices($form->ID)) { |
|
89 | 89 | |
90 | - $prices = give_get_variable_prices( $form->ID ); |
|
90 | + $prices = give_get_variable_prices($form->ID); |
|
91 | 91 | |
92 | 92 | $first = $prices[0]['_give_amount']; |
93 | - $last = array_pop( $prices ); |
|
93 | + $last = array_pop($prices); |
|
94 | 94 | $last = $last['_give_amount']; |
95 | 95 | |
96 | - if ( $first < $last ) { |
|
96 | + if ($first < $last) { |
|
97 | 97 | $min = $first; |
98 | 98 | $max = $last; |
99 | 99 | } else { |
@@ -101,51 +101,51 @@ discard block |
||
101 | 101 | $max = $first; |
102 | 102 | } |
103 | 103 | |
104 | - $price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) ); |
|
104 | + $price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max))); |
|
105 | 105 | } else { |
106 | - $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
|
106 | + $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID))); |
|
107 | 107 | } |
108 | 108 | |
109 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
110 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
109 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
110 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
111 | 111 | |
112 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
113 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
112 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
113 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
114 | 114 | |
115 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
116 | - $link = get_permalink( $form->ID ); |
|
117 | - $earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) ); |
|
115 | + $sales = give_get_form_sales_stats($form->ID); |
|
116 | + $link = get_permalink($form->ID); |
|
117 | + $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID))); |
|
118 | 118 | |
119 | - if ( function_exists( 'iconv' ) ) { |
|
119 | + if (function_exists('iconv')) { |
|
120 | 120 | // Ensure characters like euro; are properly converted. |
121 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
122 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
121 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
122 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
123 | 123 | } |
124 | 124 | |
125 | - $pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) ); |
|
125 | + $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings)); |
|
126 | 126 | endforeach; |
127 | 127 | else: |
128 | - $pdf->SetWidths( array( 280 ) ); |
|
129 | - $title = utf8_decode( sprintf( __( 'No %s found.', 'give' ), give_get_forms_label_plural() ) ); |
|
130 | - $pdf->Row( array( $title ) ); |
|
128 | + $pdf->SetWidths(array(280)); |
|
129 | + $title = utf8_decode(sprintf(__('No %s found.', 'give'), give_get_forms_label_plural())); |
|
130 | + $pdf->Row(array($title)); |
|
131 | 131 | endif; |
132 | 132 | |
133 | 133 | $pdf->Ln(); |
134 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
135 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
136 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
137 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
138 | - |
|
139 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
140 | - $image = str_replace( ' ', '%20', $image ); |
|
141 | - |
|
142 | - $pdf->SetX( 25 ); |
|
143 | - $pdf->Image( $image . '&file=.png' ); |
|
144 | - $pdf->Ln( 7 ); |
|
145 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
134 | + $pdf->SetTextColor(50, 50, 50); |
|
135 | + $pdf->SetFont('Helvetica', '', 14); |
|
136 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
137 | + $pdf->SetFont('Helvetica', '', 12); |
|
138 | + |
|
139 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
140 | + $image = str_replace(' ', '%20', $image); |
|
141 | + |
|
142 | + $pdf->SetX(25); |
|
143 | + $pdf->Image($image.'&file=.png'); |
|
144 | + $pdf->Ln(7); |
|
145 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
146 | 146 | } |
147 | 147 | |
148 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
148 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * Draws Chart for PDF Report |
@@ -162,38 +162,38 @@ discard block |
||
162 | 162 | * @return string $chart->getUrl() URL for the Google Chart |
163 | 163 | */ |
164 | 164 | function give_draw_chart_image() { |
165 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
166 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
167 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
165 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
166 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
167 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
168 | 168 | |
169 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
169 | + $chart = new GoogleChart('lc', 900, 330); |
|
170 | 170 | |
171 | 171 | $i = 1; |
172 | 172 | $earnings = ""; |
173 | 173 | $sales = ""; |
174 | 174 | |
175 | - while ( $i <= 12 ) : |
|
176 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
177 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
178 | - $i ++; |
|
175 | + while ($i <= 12) : |
|
176 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
177 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
178 | + $i++; |
|
179 | 179 | endwhile; |
180 | 180 | |
181 | - $earnings_array = explode( ",", $earnings ); |
|
182 | - $sales_array = explode( ",", $sales ); |
|
181 | + $earnings_array = explode(",", $earnings); |
|
182 | + $sales_array = explode(",", $sales); |
|
183 | 183 | |
184 | 184 | $i = 0; |
185 | - while ( $i <= 11 ) { |
|
186 | - if ( empty( $sales_array[ $i ] ) ) { |
|
187 | - $sales_array[ $i ] = 0; |
|
185 | + while ($i <= 11) { |
|
186 | + if (empty($sales_array[$i])) { |
|
187 | + $sales_array[$i] = 0; |
|
188 | 188 | } |
189 | - $i ++; |
|
189 | + $i++; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $min_earnings = 0; |
193 | - $max_earnings = max( $earnings_array ); |
|
194 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
193 | + $max_earnings = max($earnings_array); |
|
194 | + $earnings_scale = round($max_earnings, - 1); |
|
195 | 195 | |
196 | - $data = new GoogleChartData( array( |
|
196 | + $data = new GoogleChartData(array( |
|
197 | 197 | $earnings_array[0], |
198 | 198 | $earnings_array[1], |
199 | 199 | $earnings_array[2], |
@@ -206,25 +206,25 @@ discard block |
||
206 | 206 | $earnings_array[9], |
207 | 207 | $earnings_array[10], |
208 | 208 | $earnings_array[11] |
209 | - ) ); |
|
209 | + )); |
|
210 | 210 | |
211 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
212 | - $data->setColor( '1b58a3' ); |
|
213 | - $chart->addData( $data ); |
|
211 | + $data->setLegend(__('Income', 'give')); |
|
212 | + $data->setColor('1b58a3'); |
|
213 | + $chart->addData($data); |
|
214 | 214 | |
215 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
216 | - $shape_marker->setColor( '000000' ); |
|
217 | - $shape_marker->setSize( 7 ); |
|
218 | - $shape_marker->setBorder( 2 ); |
|
219 | - $shape_marker->setData( $data ); |
|
220 | - $chart->addMarker( $shape_marker ); |
|
215 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
216 | + $shape_marker->setColor('000000'); |
|
217 | + $shape_marker->setSize(7); |
|
218 | + $shape_marker->setBorder(2); |
|
219 | + $shape_marker->setData($data); |
|
220 | + $chart->addMarker($shape_marker); |
|
221 | 221 | |
222 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
223 | - $value_marker->setColor( '000000' ); |
|
224 | - $value_marker->setData( $data ); |
|
225 | - $chart->addMarker( $value_marker ); |
|
222 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
223 | + $value_marker->setColor('000000'); |
|
224 | + $value_marker->setData($data); |
|
225 | + $chart->addMarker($value_marker); |
|
226 | 226 | |
227 | - $data = new GoogleChartData( array( |
|
227 | + $data = new GoogleChartData(array( |
|
228 | 228 | $sales_array[0], |
229 | 229 | $sales_array[1], |
230 | 230 | $sales_array[2], |
@@ -237,46 +237,46 @@ discard block |
||
237 | 237 | $sales_array[9], |
238 | 238 | $sales_array[10], |
239 | 239 | $sales_array[11] |
240 | - ) ); |
|
241 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
242 | - $data->setColor( 'ff6c1c' ); |
|
243 | - $chart->addData( $data ); |
|
244 | - |
|
245 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
246 | - |
|
247 | - $chart->setScale( 0, $max_earnings ); |
|
248 | - |
|
249 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
250 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
251 | - $chart->addAxis( $y_axis ); |
|
252 | - |
|
253 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
254 | - $x_axis->setTickMarks( 5 ); |
|
255 | - $x_axis->setLabels( array( |
|
256 | - __( 'Jan', 'give' ), |
|
257 | - __( 'Feb', 'give' ), |
|
258 | - __( 'Mar', 'give' ), |
|
259 | - __( 'Apr', 'give' ), |
|
260 | - __( 'May', 'give' ), |
|
261 | - __( 'June', 'give' ), |
|
262 | - __( 'July', 'give' ), |
|
263 | - __( 'Aug', 'give' ), |
|
264 | - __( 'Sept', 'give' ), |
|
265 | - __( 'Oct', 'give' ), |
|
266 | - __( 'Nov', 'give' ), |
|
267 | - __( 'Dec', 'give' ) |
|
268 | - ) ); |
|
269 | - $chart->addAxis( $x_axis ); |
|
270 | - |
|
271 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
272 | - $shape_marker->setSize( 6 ); |
|
273 | - $shape_marker->setBorder( 2 ); |
|
274 | - $shape_marker->setData( $data ); |
|
275 | - $chart->addMarker( $shape_marker ); |
|
276 | - |
|
277 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
278 | - $value_marker->setData( $data ); |
|
279 | - $chart->addMarker( $value_marker ); |
|
240 | + )); |
|
241 | + $data->setLegend(__('Donations', 'give')); |
|
242 | + $data->setColor('ff6c1c'); |
|
243 | + $chart->addData($data); |
|
244 | + |
|
245 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
246 | + |
|
247 | + $chart->setScale(0, $max_earnings); |
|
248 | + |
|
249 | + $y_axis = new GoogleChartAxis('y'); |
|
250 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
251 | + $chart->addAxis($y_axis); |
|
252 | + |
|
253 | + $x_axis = new GoogleChartAxis('x'); |
|
254 | + $x_axis->setTickMarks(5); |
|
255 | + $x_axis->setLabels(array( |
|
256 | + __('Jan', 'give'), |
|
257 | + __('Feb', 'give'), |
|
258 | + __('Mar', 'give'), |
|
259 | + __('Apr', 'give'), |
|
260 | + __('May', 'give'), |
|
261 | + __('June', 'give'), |
|
262 | + __('July', 'give'), |
|
263 | + __('Aug', 'give'), |
|
264 | + __('Sept', 'give'), |
|
265 | + __('Oct', 'give'), |
|
266 | + __('Nov', 'give'), |
|
267 | + __('Dec', 'give') |
|
268 | + )); |
|
269 | + $chart->addAxis($x_axis); |
|
270 | + |
|
271 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
272 | + $shape_marker->setSize(6); |
|
273 | + $shape_marker->setBorder(2); |
|
274 | + $shape_marker->setData($data); |
|
275 | + $chart->addMarker($shape_marker); |
|
276 | + |
|
277 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
278 | + $value_marker->setData($data); |
|
279 | + $chart->addMarker($value_marker); |
|
280 | 280 | |
281 | 281 | return $chart->getUrl(); |
282 | 282 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $tag Email tag to be replace in email |
55 | 55 | * @param callable $func Hook to run when email tag is found |
56 | 56 | */ |
57 | - public function add( $tag, $description, $func ) { |
|
58 | - if ( is_callable( $func ) ) { |
|
59 | - $this->tags[ $tag ] = array( |
|
57 | + public function add($tag, $description, $func) { |
|
58 | + if (is_callable($func)) { |
|
59 | + $this->tags[$tag] = array( |
|
60 | 60 | 'tag' => $tag, |
61 | 61 | 'description' => $description, |
62 | 62 | 'func' => $func |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $tag Email tag to remove hook from |
73 | 73 | */ |
74 | - public function remove( $tag ) { |
|
75 | - unset( $this->tags[ $tag ] ); |
|
74 | + public function remove($tag) { |
|
75 | + unset($this->tags[$tag]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function email_tag_exists( $tag ) { |
|
88 | - return array_key_exists( $tag, $this->tags ); |
|
87 | + public function email_tag_exists($tag) { |
|
88 | + return array_key_exists($tag, $this->tags); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Content with email tags filtered out. |
111 | 111 | */ |
112 | - public function do_tags( $content, $payment_id ) { |
|
112 | + public function do_tags($content, $payment_id) { |
|
113 | 113 | |
114 | 114 | // Check if there is atleast one tag added |
115 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
115 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
116 | 116 | return $content; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->payment_id = $payment_id; |
120 | 120 | |
121 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
121 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
122 | 122 | |
123 | 123 | $this->payment_id = null; |
124 | 124 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function do_tag( $m ) { |
|
137 | + public function do_tag($m) { |
|
138 | 138 | |
139 | 139 | // Get tag |
140 | 140 | $tag = $m[1]; |
141 | 141 | |
142 | 142 | // Return tag if tag not set |
143 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
143 | + if ( ! $this->email_tag_exists($tag)) { |
|
144 | 144 | return $m[0]; |
145 | 145 | } |
146 | 146 | |
147 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
147 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $description Description of the email tag added |
159 | 159 | * @param callable $func Hook to run when email tag is found |
160 | 160 | */ |
161 | -function give_add_email_tag( $tag, $description, $func ) { |
|
162 | - Give()->email_tags->add( $tag, $description, $func ); |
|
161 | +function give_add_email_tag($tag, $description, $func) { |
|
162 | + Give()->email_tags->add($tag, $description, $func); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param string $tag Email tag to remove hook from |
171 | 171 | */ |
172 | -function give_remove_email_tag( $tag ) { |
|
173 | - Give()->email_tags->remove( $tag ); |
|
172 | +function give_remove_email_tag($tag) { |
|
173 | + Give()->email_tags->remove($tag); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | -function give_email_tag_exists( $tag ) { |
|
186 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
185 | +function give_email_tag_exists($tag) { |
|
186 | + return Give()->email_tags->email_tag_exists($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $email_tags = give_get_email_tags(); |
213 | 213 | |
214 | 214 | // Check |
215 | - if ( count( $email_tags ) > 0 ) { |
|
215 | + if (count($email_tags) > 0) { |
|
216 | 216 | |
217 | 217 | // Loop |
218 | - foreach ( $email_tags as $email_tag ) { |
|
218 | + foreach ($email_tags as $email_tag) { |
|
219 | 219 | |
220 | 220 | // Add email tag to list |
221 | - $list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>'; |
|
221 | + $list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>'; |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string Content with email tags filtered out. |
240 | 240 | */ |
241 | -function give_do_email_tags( $content, $payment_id ) { |
|
241 | +function give_do_email_tags($content, $payment_id) { |
|
242 | 242 | |
243 | 243 | // Replace all tags |
244 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
244 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
245 | 245 | |
246 | 246 | // Maintaining backwards compatibility |
247 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
247 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
248 | 248 | |
249 | 249 | // Return content |
250 | 250 | return $content; |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | * @since 1.0 |
257 | 257 | */ |
258 | 258 | function give_load_email_tags() { |
259 | - do_action( 'give_add_email_tags' ); |
|
259 | + do_action('give_add_email_tags'); |
|
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
262 | +add_action('init', 'give_load_email_tags', - 999); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Add default Give email template tags |
@@ -272,82 +272,82 @@ discard block |
||
272 | 272 | $email_tags = array( |
273 | 273 | array( |
274 | 274 | 'tag' => 'donation', |
275 | - 'description' => __( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ), |
|
275 | + 'description' => __('The name of completed donation form and the donation level chosen if applicable.', 'give'), |
|
276 | 276 | 'function' => 'give_email_tag_donation' |
277 | 277 | ), |
278 | 278 | array( |
279 | 279 | 'tag' => 'name', |
280 | - 'description' => __( 'The donor\'s first name.', 'give' ), |
|
280 | + 'description' => __('The donor\'s first name.', 'give'), |
|
281 | 281 | 'function' => 'give_email_tag_first_name' |
282 | 282 | ), |
283 | 283 | array( |
284 | 284 | 'tag' => 'fullname', |
285 | - 'description' => __( 'The donor\'s full name, first and last.', 'give' ), |
|
285 | + 'description' => __('The donor\'s full name, first and last.', 'give'), |
|
286 | 286 | 'function' => 'give_email_tag_fullname' |
287 | 287 | ), |
288 | 288 | array( |
289 | 289 | 'tag' => 'username', |
290 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
290 | + 'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
291 | 291 | 'function' => 'give_email_tag_username' |
292 | 292 | ), |
293 | 293 | array( |
294 | 294 | 'tag' => 'user_email', |
295 | - 'description' => __( 'The donor\'s email address.', 'give' ), |
|
295 | + 'description' => __('The donor\'s email address.', 'give'), |
|
296 | 296 | 'function' => 'give_email_tag_user_email' |
297 | 297 | ), |
298 | 298 | array( |
299 | 299 | 'tag' => 'billing_address', |
300 | - 'description' => __( 'The donor\'s billing address.', 'give' ), |
|
300 | + 'description' => __('The donor\'s billing address.', 'give'), |
|
301 | 301 | 'function' => 'give_email_tag_billing_address' |
302 | 302 | ), |
303 | 303 | array( |
304 | 304 | 'tag' => 'date', |
305 | - 'description' => __( 'The date of the donation.', 'give' ), |
|
305 | + 'description' => __('The date of the donation.', 'give'), |
|
306 | 306 | 'function' => 'give_email_tag_date' |
307 | 307 | ), |
308 | 308 | array( |
309 | 309 | 'tag' => 'price', |
310 | - 'description' => __( 'The total price of the donation.', 'give' ), |
|
310 | + 'description' => __('The total price of the donation.', 'give'), |
|
311 | 311 | 'function' => 'give_email_tag_price' |
312 | 312 | ), |
313 | 313 | array( |
314 | 314 | 'tag' => 'payment_id', |
315 | - 'description' => __( 'The unique ID number for this donation.', 'give' ), |
|
315 | + 'description' => __('The unique ID number for this donation.', 'give'), |
|
316 | 316 | 'function' => 'give_email_tag_payment_id' |
317 | 317 | ), |
318 | 318 | array( |
319 | 319 | 'tag' => 'receipt_id', |
320 | - 'description' => __( 'The unique ID number for this donation receipt.', 'give' ), |
|
320 | + 'description' => __('The unique ID number for this donation receipt.', 'give'), |
|
321 | 321 | 'function' => 'give_email_tag_receipt_id' |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'payment_method', |
325 | - 'description' => __( 'The method of payment used for this donation.', 'give' ), |
|
325 | + 'description' => __('The method of payment used for this donation.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_payment_method' |
327 | 327 | ), |
328 | 328 | array( |
329 | 329 | 'tag' => 'sitename', |
330 | - 'description' => __( 'Your site name', 'give' ), |
|
330 | + 'description' => __('Your site name', 'give'), |
|
331 | 331 | 'function' => 'give_email_tag_sitename' |
332 | 332 | ), |
333 | 333 | array( |
334 | 334 | 'tag' => 'receipt_link', |
335 | - 'description' => __( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ), |
|
335 | + 'description' => __('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'), |
|
336 | 336 | 'function' => 'give_email_tag_receipt_link' |
337 | 337 | ), |
338 | 338 | ); |
339 | 339 | |
340 | 340 | // Apply give_email_tags filter |
341 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
341 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
342 | 342 | |
343 | 343 | // Add email tags |
344 | - foreach ( $email_tags as $email_tag ) { |
|
345 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
344 | + foreach ($email_tags as $email_tag) { |
|
345 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
350 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
351 | 351 | |
352 | 352 | |
353 | 353 | /** |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string name |
360 | 360 | */ |
361 | -function give_email_tag_first_name( $payment_id ) { |
|
362 | - $payment = new Give_Payment( $payment_id ); |
|
361 | +function give_email_tag_first_name($payment_id) { |
|
362 | + $payment = new Give_Payment($payment_id); |
|
363 | 363 | $user_info = $payment->user_info; |
364 | 364 | |
365 | - if ( empty( $user_info ) ) { |
|
365 | + if (empty($user_info)) { |
|
366 | 366 | return ''; |
367 | 367 | } |
368 | 368 | |
369 | - $email_name = give_get_email_names( $user_info ); |
|
369 | + $email_name = give_get_email_names($user_info); |
|
370 | 370 | |
371 | 371 | return $email_name['name']; |
372 | 372 | } |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string fullname |
381 | 381 | */ |
382 | -function give_email_tag_fullname( $payment_id ) { |
|
383 | - $payment = new Give_Payment( $payment_id ); |
|
382 | +function give_email_tag_fullname($payment_id) { |
|
383 | + $payment = new Give_Payment($payment_id); |
|
384 | 384 | $user_info = $payment->user_info; |
385 | 385 | |
386 | - if ( empty( $user_info ) ) { |
|
386 | + if (empty($user_info)) { |
|
387 | 387 | return ''; |
388 | 388 | } |
389 | 389 | |
390 | - $email_name = give_get_email_names( $user_info ); |
|
390 | + $email_name = give_get_email_names($user_info); |
|
391 | 391 | |
392 | 392 | return $email_name['fullname']; |
393 | 393 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string username |
402 | 402 | */ |
403 | -function give_email_tag_username( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_username($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['username']; |
414 | 414 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string user_email |
423 | 423 | */ |
424 | -function give_email_tag_user_email( $payment_id ) { |
|
425 | - $payment = new Give_Payment( $payment_id ); |
|
424 | +function give_email_tag_user_email($payment_id) { |
|
425 | + $payment = new Give_Payment($payment_id); |
|
426 | 426 | |
427 | 427 | return $payment->email; |
428 | 428 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string billing_address |
437 | 437 | */ |
438 | -function give_email_tag_billing_address( $payment_id ) { |
|
438 | +function give_email_tag_billing_address($payment_id) { |
|
439 | 439 | |
440 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
441 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
440 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
441 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
442 | 442 | 'line1' => '', |
443 | 443 | 'line2' => '', |
444 | 444 | 'city' => '', |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | 'zip' => '' |
448 | 448 | ); |
449 | 449 | |
450 | - $return = $user_address['line1'] . "\n"; |
|
451 | - if ( ! empty( $user_address['line2'] ) ) { |
|
452 | - $return .= $user_address['line2'] . "\n"; |
|
450 | + $return = $user_address['line1']."\n"; |
|
451 | + if ( ! empty($user_address['line2'])) { |
|
452 | + $return .= $user_address['line2']."\n"; |
|
453 | 453 | } |
454 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
454 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
455 | 455 | $return .= $user_address['country']; |
456 | 456 | |
457 | 457 | return $return; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string date |
467 | 467 | */ |
468 | -function give_email_tag_date( $payment_id ) { |
|
469 | - $payment = new Give_Payment( $payment_id ); |
|
468 | +function give_email_tag_date($payment_id) { |
|
469 | + $payment = new Give_Payment($payment_id); |
|
470 | 470 | |
471 | - return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) ); |
|
471 | + return date_i18n(get_option('date_format'), strtotime($payment->date)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string price |
481 | 481 | */ |
482 | -function give_email_tag_price( $payment_id ) { |
|
483 | - $payment = new Give_Payment( $payment_id ); |
|
484 | - $price = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
482 | +function give_email_tag_price($payment_id) { |
|
483 | + $payment = new Give_Payment($payment_id); |
|
484 | + $price = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
485 | 485 | |
486 | - return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' ); |
|
486 | + return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return int payment_id |
496 | 496 | */ |
497 | -function give_email_tag_payment_id( $payment_id ) { |
|
498 | - $payment = new Give_Payment( $payment_id ); |
|
497 | +function give_email_tag_payment_id($payment_id) { |
|
498 | + $payment = new Give_Payment($payment_id); |
|
499 | 499 | |
500 | 500 | return $payment->number; |
501 | 501 | } |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string receipt_id |
510 | 510 | */ |
511 | -function give_email_tag_receipt_id( $payment_id ) { |
|
512 | - $payment = new Give_Payment( $payment_id ); |
|
511 | +function give_email_tag_receipt_id($payment_id) { |
|
512 | + $payment = new Give_Payment($payment_id); |
|
513 | 513 | |
514 | 514 | return $payment->key; |
515 | 515 | } |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @return string $form_title |
525 | 525 | */ |
526 | -function give_email_tag_donation( $payment_id ) { |
|
527 | - $payment = new Give_Payment( $payment_id ); |
|
528 | - $form_title = give_get_payment_form_title( $payment->meta, false, '-' ); |
|
526 | +function give_email_tag_donation($payment_id) { |
|
527 | + $payment = new Give_Payment($payment_id); |
|
528 | + $form_title = give_get_payment_form_title($payment->meta, false, '-'); |
|
529 | 529 | |
530 | - return ! empty( $form_title ) ? $form_title : __( 'There was an error retrieving this donation title.', 'give' ); |
|
530 | + return ! empty($form_title) ? $form_title : __('There was an error retrieving this donation title.', 'give'); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string gateway |
541 | 541 | */ |
542 | -function give_email_tag_payment_method( $payment_id ) { |
|
543 | - $payment = new Give_Payment( $payment_id ); |
|
542 | +function give_email_tag_payment_method($payment_id) { |
|
543 | + $payment = new Give_Payment($payment_id); |
|
544 | 544 | |
545 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
545 | + return give_get_gateway_checkout_label($payment->gateway); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return string sitename |
555 | 555 | */ |
556 | -function give_email_tag_sitename( $payment_id ) { |
|
557 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
556 | +function give_email_tag_sitename($payment_id) { |
|
557 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return string receipt_link |
568 | 568 | */ |
569 | -function give_email_tag_receipt_link( $payment_id ) { |
|
569 | +function give_email_tag_receipt_link($payment_id) { |
|
570 | 570 | |
571 | - $receipt_url = esc_url( add_query_arg( array( |
|
572 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
571 | + $receipt_url = esc_url(add_query_arg(array( |
|
572 | + 'payment_key' => give_get_payment_key($payment_id), |
|
573 | 573 | 'give_action' => 'view_receipt' |
574 | - ), home_url() ) ); |
|
575 | - $formatted = sprintf( |
|
574 | + ), home_url())); |
|
575 | + $formatted = sprintf( |
|
576 | 576 | '<a href="%1$s">%2$s</a>', |
577 | 577 | $receipt_url, |
578 | - __( 'View it in your browser', 'give' ) |
|
578 | + __('View it in your browser', 'give') |
|
579 | 579 | ); |
580 | 580 | |
581 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
581 | + if (give_get_option('email_template') !== 'none') { |
|
582 | 582 | return $formatted; |
583 | 583 | } else { |
584 | 584 | return $receipt_url; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - if ( 'none' === $this->get_template() ) { |
|
82 | + if ('none' === $this->get_template()) { |
|
83 | 83 | $this->html = false; |
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - public function __set( $key, $value ) { |
|
96 | + public function __set($key, $value) { |
|
97 | 97 | $this->$key = $value; |
98 | 98 | } |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | 105 | public function get_from_name() { |
106 | - if ( ! $this->from_name ) { |
|
107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
106 | + if ( ! $this->from_name) { |
|
107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | 118 | public function get_from_address() { |
119 | - if ( ! $this->from_address ) { |
|
120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
119 | + if ( ! $this->from_address) { |
|
120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_content_type() { |
132 | - if ( ! $this->content_type && $this->html ) { |
|
133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
134 | - } else if ( ! $this->html ) { |
|
132 | + if ( ! $this->content_type && $this->html) { |
|
133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
134 | + } else if ( ! $this->html) { |
|
135 | 135 | $this->content_type = 'text/plain'; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | */ |
146 | 146 | public function get_headers() { |
147 | - if ( ! $this->headers ) { |
|
147 | + if ( ! $this->headers) { |
|
148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_templates() { |
162 | 162 | $templates = array( |
163 | - 'default' => __( 'Default Template', 'give' ), |
|
164 | - 'none' => __( 'No template, plain text only', 'give' ) |
|
163 | + 'default' => __('Default Template', 'give'), |
|
164 | + 'none' => __('No template, plain text only', 'give') |
|
165 | 165 | ); |
166 | 166 | |
167 | - return apply_filters( 'give_email_templates', $templates ); |
|
167 | + return apply_filters('give_email_templates', $templates); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @since 1.0 |
174 | 174 | */ |
175 | 175 | public function get_template() { |
176 | - if ( ! $this->template ) { |
|
177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
176 | + if ( ! $this->template) { |
|
177 | + $this->template = give_get_option('email_template', 'default'); |
|
178 | 178 | } |
179 | 179 | |
180 | - return apply_filters( 'give_email_template', $this->template ); |
|
180 | + return apply_filters('give_email_template', $this->template); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | 188 | public function get_heading() { |
189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
189 | + return apply_filters('give_email_heading', $this->heading); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function parse_tags( $content ) { |
|
199 | + public function parse_tags($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
@@ -205,36 +205,36 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - public function build_email( $message ) { |
|
208 | + public function build_email($message) { |
|
209 | 209 | |
210 | - if ( false === $this->html ) { |
|
211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
210 | + if (false === $this->html) { |
|
211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
212 | 212 | } |
213 | 213 | |
214 | - $message = $this->text_to_html( $message ); |
|
214 | + $message = $this->text_to_html($message); |
|
215 | 215 | |
216 | 216 | ob_start(); |
217 | 217 | |
218 | - give_get_template_part( 'emails/header', $this->get_template(), true ); |
|
218 | + give_get_template_part('emails/header', $this->get_template(), true); |
|
219 | 219 | |
220 | - do_action( 'give_email_header', $this ); |
|
220 | + do_action('give_email_header', $this); |
|
221 | 221 | |
222 | - if ( has_action( 'give_email_template_' . $this->get_template() ) ) { |
|
223 | - do_action( 'give_email_template_' . $this->get_template() ); |
|
222 | + if (has_action('give_email_template_'.$this->get_template())) { |
|
223 | + do_action('give_email_template_'.$this->get_template()); |
|
224 | 224 | } else { |
225 | - give_get_template_part( 'emails/body', $this->get_template(), true ); |
|
225 | + give_get_template_part('emails/body', $this->get_template(), true); |
|
226 | 226 | } |
227 | 227 | |
228 | - do_action( 'give_email_body', $this ); |
|
228 | + do_action('give_email_body', $this); |
|
229 | 229 | |
230 | - give_get_template_part( 'emails/footer', $this->get_template(), true ); |
|
230 | + give_get_template_part('emails/footer', $this->get_template(), true); |
|
231 | 231 | |
232 | - do_action( 'give_email_footer', $this ); |
|
232 | + do_action('give_email_footer', $this); |
|
233 | 233 | |
234 | 234 | $body = ob_get_clean(); |
235 | - $message = str_replace( '{email}', $message, $body ); |
|
235 | + $message = str_replace('{email}', $message, $body); |
|
236 | 236 | |
237 | - return apply_filters( 'give_email_message', $message, $this ); |
|
237 | + return apply_filters('give_email_message', $message, $this); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -247,26 +247,26 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return bool |
249 | 249 | */ |
250 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
250 | + public function send($to, $subject, $message, $attachments = '') { |
|
251 | 251 | |
252 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
253 | - _doing_it_wrong( __FUNCTION__, __( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
252 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
253 | + _doing_it_wrong(__FUNCTION__, __('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
254 | 254 | |
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | |
258 | - do_action( 'give_email_send_before', $this ); |
|
258 | + do_action('give_email_send_before', $this); |
|
259 | 259 | |
260 | - $subject = $this->parse_tags( $subject ); |
|
261 | - $message = $this->parse_tags( $message ); |
|
260 | + $subject = $this->parse_tags($subject); |
|
261 | + $message = $this->parse_tags($message); |
|
262 | 262 | |
263 | - $message = $this->build_email( $message ); |
|
263 | + $message = $this->build_email($message); |
|
264 | 264 | |
265 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
265 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
266 | 266 | |
267 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
267 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
268 | 268 | |
269 | - do_action( 'give_email_send_after', $this ); |
|
269 | + do_action('give_email_send_after', $this); |
|
270 | 270 | |
271 | 271 | return $sent; |
272 | 272 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | * @since 1.0 |
279 | 279 | */ |
280 | 280 | public function send_before() { |
281 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
282 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
283 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
281 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
282 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
283 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | * @since 1.0 |
290 | 290 | */ |
291 | 291 | public function send_after() { |
292 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
293 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
294 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
292 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
293 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
294 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
295 | 295 | |
296 | 296 | // Reset heading to an empty string |
297 | 297 | $this->heading = ''; |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @since 1.0 |
304 | 304 | */ |
305 | - public function text_to_html( $message ) { |
|
305 | + public function text_to_html($message) { |
|
306 | 306 | |
307 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
308 | - $message = wpautop( $message ); |
|
307 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
308 | + $message = wpautop($message); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | return $message; |