@@ -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 | |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * @since 1.8 |
21 | 21 | */ |
22 | 22 | function give_load_wp_editor() { |
23 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
23 | + if ( ! isset($_POST['wp_editor'])) { |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
27 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
28 | 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
29 | 29 | |
30 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
30 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
31 | 31 | |
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
35 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | ); |
53 | 53 | |
54 | 54 | // Get current page. |
55 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
55 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
56 | 56 | |
57 | 57 | // Bailout. |
58 | 58 | if ( |
59 | - empty( $current_page ) |
|
60 | - || empty( $_GET['_wp_http_referer'] ) |
|
61 | - || ! in_array( $current_page, $give_pages ) |
|
59 | + empty($current_page) |
|
60 | + || empty($_GET['_wp_http_referer']) |
|
61 | + || ! in_array($current_page, $give_pages) |
|
62 | 62 | ) { |
63 | 63 | return false; |
64 | 64 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @since 1.8 |
70 | 70 | */ |
71 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
71 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
72 | 72 | |
73 | - if ( $redirect ) { |
|
73 | + if ($redirect) { |
|
74 | 74 | // Redirect. |
75 | 75 | wp_redirect( |
76 | 76 | remove_query_arg( |
77 | - array( '_wp_http_referer', '_wpnonce' ), |
|
78 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
77 | + array('_wp_http_referer', '_wpnonce'), |
|
78 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
85 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | /** |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function give_hide_outdated_php_notice() { |
98 | 98 | |
99 | - if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
99 | + if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) { |
|
100 | 100 | give_die(); |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Transient key name. |
104 | 104 | $transient_key = "_give_hide_outdated_php_notices_shortly"; |
105 | 105 | |
106 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
106 | + if (Give_Cache::get($transient_key, true)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Hide notice for 24 hours. |
111 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
111 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
112 | 112 | |
113 | 113 | give_die(); |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
117 | +add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Register admin notices. |
@@ -123,27 +123,27 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _give_register_admin_notices() { |
125 | 125 | // Bailout. |
126 | - if ( ! is_admin() ) { |
|
126 | + if ( ! is_admin()) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Bulk action notices. |
131 | 131 | if ( |
132 | - isset( $_GET['action'] ) && |
|
133 | - ! empty( $_GET['action'] ) |
|
132 | + isset($_GET['action']) && |
|
133 | + ! empty($_GET['action']) |
|
134 | 134 | ) { |
135 | 135 | |
136 | 136 | // Add payment bulk notice. |
137 | 137 | if ( |
138 | - current_user_can( 'edit_give_payments' ) && |
|
139 | - isset( $_GET['payment'] ) && |
|
140 | - ! empty( $_GET['payment'] ) |
|
138 | + current_user_can('edit_give_payments') && |
|
139 | + isset($_GET['payment']) && |
|
140 | + ! empty($_GET['payment']) |
|
141 | 141 | ) { |
142 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
142 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
143 | 143 | |
144 | - switch ( $_GET['action'] ) { |
|
144 | + switch ($_GET['action']) { |
|
145 | 145 | case 'delete': |
146 | - Give()->notices->register_notice( array( |
|
146 | + Give()->notices->register_notice(array( |
|
147 | 147 | 'id' => 'bulk_action_delete', |
148 | 148 | 'type' => 'updated', |
149 | 149 | 'description' => sprintf( |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | ), |
156 | 156 | $payment_count ), |
157 | 157 | 'show' => true, |
158 | - ) ); |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | break; |
161 | 161 | |
162 | 162 | case 'resend-receipt': |
163 | - Give()->notices->register_notice( array( |
|
163 | + Give()->notices->register_notice(array( |
|
164 | 164 | 'id' => 'bulk_action_resend_receipt', |
165 | 165 | 'type' => 'updated', |
166 | 166 | 'description' => sprintf( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $payment_count |
174 | 174 | ), |
175 | 175 | 'show' => true, |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | break; |
178 | 178 | |
179 | 179 | case 'set-status-publish' : |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | case 'set-status-cancelled' : |
186 | 186 | case 'set-status-abandoned' : |
187 | 187 | case 'set-status-preapproval' : |
188 | - Give()->notices->register_notice( array( |
|
188 | + Give()->notices->register_notice(array( |
|
189 | 189 | 'id' => 'bulk_action_status_change', |
190 | 190 | 'type' => 'updated', |
191 | 191 | 'description' => _n( |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | 'give' |
196 | 196 | ), |
197 | 197 | 'show' => true, |
198 | - ) ); |
|
198 | + )); |
|
199 | 199 | break; |
200 | 200 | } |
201 | 201 | |
@@ -203,244 +203,244 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // Add give message notices. |
206 | - if ( ! empty( $_GET['give-message'] ) ) { |
|
206 | + if ( ! empty($_GET['give-message'])) { |
|
207 | 207 | // Donation reports errors. |
208 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
209 | - switch ( $_GET['give-message'] ) { |
|
208 | + if (current_user_can('view_give_reports')) { |
|
209 | + switch ($_GET['give-message']) { |
|
210 | 210 | case 'donation_deleted' : |
211 | - Give()->notices->register_notice( array( |
|
211 | + Give()->notices->register_notice(array( |
|
212 | 212 | 'id' => 'give-donation-deleted', |
213 | 213 | 'type' => 'updated', |
214 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
214 | + 'description' => __('The donation has been deleted.', 'give'), |
|
215 | 215 | 'show' => true, |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | break; |
218 | 218 | case 'email_sent' : |
219 | - Give()->notices->register_notice( array( |
|
219 | + Give()->notices->register_notice(array( |
|
220 | 220 | 'id' => 'give-payment-sent', |
221 | 221 | 'type' => 'updated', |
222 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
222 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
223 | 223 | 'show' => true, |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | break; |
226 | 226 | case 'refreshed-reports' : |
227 | - Give()->notices->register_notice( array( |
|
227 | + Give()->notices->register_notice(array( |
|
228 | 228 | 'id' => 'give-refreshed-reports', |
229 | 229 | 'type' => 'updated', |
230 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
230 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
231 | 231 | 'show' => true, |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | break; |
234 | 234 | case 'donation-note-deleted' : |
235 | - Give()->notices->register_notice( array( |
|
235 | + Give()->notices->register_notice(array( |
|
236 | 236 | 'id' => 'give-donation-note-deleted', |
237 | 237 | 'type' => 'updated', |
238 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
238 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
239 | 239 | 'show' => true, |
240 | - ) ); |
|
240 | + )); |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Give settings notices and errors. |
246 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
247 | - switch ( $_GET['give-message'] ) { |
|
246 | + if (current_user_can('manage_give_settings')) { |
|
247 | + switch ($_GET['give-message']) { |
|
248 | 248 | case 'settings-imported' : |
249 | - Give()->notices->register_notice( array( |
|
249 | + Give()->notices->register_notice(array( |
|
250 | 250 | 'id' => 'give-settings-imported', |
251 | 251 | 'type' => 'updated', |
252 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
252 | + 'description' => __('The settings have been imported.', 'give'), |
|
253 | 253 | 'show' => true, |
254 | - ) ); |
|
254 | + )); |
|
255 | 255 | break; |
256 | 256 | case 'api-key-generated' : |
257 | - Give()->notices->register_notice( array( |
|
257 | + Give()->notices->register_notice(array( |
|
258 | 258 | 'id' => 'give-api-key-generated', |
259 | 259 | 'type' => 'updated', |
260 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
260 | + 'description' => __('API keys have been generated.', 'give'), |
|
261 | 261 | 'show' => true, |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | break; |
264 | 264 | case 'api-key-exists' : |
265 | - Give()->notices->register_notice( array( |
|
265 | + Give()->notices->register_notice(array( |
|
266 | 266 | 'id' => 'give-api-key-exists', |
267 | 267 | 'type' => 'updated', |
268 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
268 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
269 | 269 | 'show' => true, |
270 | - ) ); |
|
270 | + )); |
|
271 | 271 | break; |
272 | 272 | case 'api-key-regenerated' : |
273 | - Give()->notices->register_notice( array( |
|
273 | + Give()->notices->register_notice(array( |
|
274 | 274 | 'id' => 'give-api-key-regenerated', |
275 | 275 | 'type' => 'updated', |
276 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
276 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
277 | 277 | 'show' => true, |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | break; |
280 | 280 | case 'api-key-revoked' : |
281 | - Give()->notices->register_notice( array( |
|
281 | + Give()->notices->register_notice(array( |
|
282 | 282 | 'id' => 'give-api-key-revoked', |
283 | 283 | 'type' => 'updated', |
284 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
284 | + 'description' => __('API keys have been revoked.', 'give'), |
|
285 | 285 | 'show' => true, |
286 | - ) ); |
|
286 | + )); |
|
287 | 287 | break; |
288 | 288 | case 'sent-test-email' : |
289 | - Give()->notices->register_notice( array( |
|
289 | + Give()->notices->register_notice(array( |
|
290 | 290 | 'id' => 'give-sent-test-email', |
291 | 291 | 'type' => 'updated', |
292 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
292 | + 'description' => __('The test email has been sent.', 'give'), |
|
293 | 293 | 'show' => true, |
294 | - ) ); |
|
294 | + )); |
|
295 | 295 | break; |
296 | 296 | case 'matched-success-failure-page': |
297 | - Give()->notices->register_notice( array( |
|
297 | + Give()->notices->register_notice(array( |
|
298 | 298 | 'id' => 'give-matched-success-failure-page', |
299 | 299 | 'type' => 'updated', |
300 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
300 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
301 | 301 | 'show' => true, |
302 | - ) ); |
|
302 | + )); |
|
303 | 303 | break; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | // Payments errors. |
307 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
308 | - switch ( $_GET['give-message'] ) { |
|
307 | + if (current_user_can('edit_give_payments')) { |
|
308 | + switch ($_GET['give-message']) { |
|
309 | 309 | case 'note-added' : |
310 | - Give()->notices->register_notice( array( |
|
310 | + Give()->notices->register_notice(array( |
|
311 | 311 | 'id' => 'give-note-added', |
312 | 312 | 'type' => 'updated', |
313 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
313 | + 'description' => __('The donation note has been added.', 'give'), |
|
314 | 314 | 'show' => true, |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | break; |
317 | 317 | case 'payment-updated' : |
318 | - Give()->notices->register_notice( array( |
|
318 | + Give()->notices->register_notice(array( |
|
319 | 319 | 'id' => 'give-payment-updated', |
320 | 320 | 'type' => 'updated', |
321 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
321 | + 'description' => __('The donation has been updated.', 'give'), |
|
322 | 322 | 'show' => true, |
323 | - ) ); |
|
323 | + )); |
|
324 | 324 | break; |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | 328 | // Donor Notices. |
329 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
330 | - switch ( $_GET['give-message'] ) { |
|
329 | + if (current_user_can('edit_give_payments')) { |
|
330 | + switch ($_GET['give-message']) { |
|
331 | 331 | case 'donor-deleted' : |
332 | - Give()->notices->register_notice( array( |
|
332 | + Give()->notices->register_notice(array( |
|
333 | 333 | 'id' => 'give-donor-deleted', |
334 | 334 | 'type' => 'updated', |
335 | - 'description' => __( 'The selected donor(s) has been deleted.', 'give' ), |
|
335 | + 'description' => __('The selected donor(s) has been deleted.', 'give'), |
|
336 | 336 | 'show' => true, |
337 | - ) ); |
|
337 | + )); |
|
338 | 338 | break; |
339 | 339 | |
340 | 340 | case 'donor-donations-deleted' : |
341 | - Give()->notices->register_notice( array( |
|
341 | + Give()->notices->register_notice(array( |
|
342 | 342 | 'id' => 'give-donor-donations-deleted', |
343 | 343 | 'type' => 'updated', |
344 | - 'description' => __( 'The selected donor(s) and its associated donations has been deleted.', 'give' ), |
|
344 | + 'description' => __('The selected donor(s) and its associated donations has been deleted.', 'give'), |
|
345 | 345 | 'show' => true, |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | break; |
348 | 348 | |
349 | 349 | case 'confirm-delete-donor' : |
350 | - Give()->notices->register_notice( array( |
|
350 | + Give()->notices->register_notice(array( |
|
351 | 351 | 'id' => 'give-confirm-delete-donor', |
352 | 352 | 'type' => 'updated', |
353 | - 'description' => __( 'You must confirm to delete the selected donor(s).', 'give' ), |
|
353 | + 'description' => __('You must confirm to delete the selected donor(s).', 'give'), |
|
354 | 354 | 'show' => true, |
355 | - ) ); |
|
355 | + )); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'invalid-donor-id' : |
359 | - Give()->notices->register_notice( array( |
|
359 | + Give()->notices->register_notice(array( |
|
360 | 360 | 'id' => 'give-invalid-donor-id', |
361 | 361 | 'type' => 'updated', |
362 | - 'description' => __( 'Invalid Donor ID.', 'give' ), |
|
362 | + 'description' => __('Invalid Donor ID.', 'give'), |
|
363 | 363 | 'show' => true, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | break; |
366 | 366 | |
367 | 367 | case 'donor-delete-failed' : |
368 | - Give()->notices->register_notice( array( |
|
368 | + Give()->notices->register_notice(array( |
|
369 | 369 | 'id' => 'give-donor-delete-failed', |
370 | 370 | 'type' => 'error', |
371 | - 'description' => __( 'Unable to delete selected donor(s).', 'give' ), |
|
371 | + 'description' => __('Unable to delete selected donor(s).', 'give'), |
|
372 | 372 | 'show' => true, |
373 | - ) ); |
|
373 | + )); |
|
374 | 374 | break; |
375 | 375 | |
376 | 376 | case 'email-added' : |
377 | - Give()->notices->register_notice( array( |
|
377 | + Give()->notices->register_notice(array( |
|
378 | 378 | 'id' => 'give-donor-email-added', |
379 | 379 | 'type' => 'updated', |
380 | - 'description' => __( 'Donor email added.', 'give' ), |
|
380 | + 'description' => __('Donor email added.', 'give'), |
|
381 | 381 | 'show' => true, |
382 | - ) ); |
|
382 | + )); |
|
383 | 383 | break; |
384 | 384 | |
385 | 385 | case 'email-removed' : |
386 | - Give()->notices->register_notice( array( |
|
386 | + Give()->notices->register_notice(array( |
|
387 | 387 | 'id' => 'give-donor-email-removed', |
388 | 388 | 'type' => 'updated', |
389 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
389 | + 'description' => __('Donor email removed.', 'give'), |
|
390 | 390 | 'show' => true, |
391 | - ) ); |
|
391 | + )); |
|
392 | 392 | break; |
393 | 393 | |
394 | 394 | case 'email-remove-failed' : |
395 | - Give()->notices->register_notice( array( |
|
395 | + Give()->notices->register_notice(array( |
|
396 | 396 | 'id' => 'give-donor-email-remove-failed', |
397 | 397 | 'type' => 'updated', |
398 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
398 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
399 | 399 | 'show' => true, |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | break; |
402 | 402 | |
403 | 403 | case 'primary-email-updated' : |
404 | - Give()->notices->register_notice( array( |
|
404 | + Give()->notices->register_notice(array( |
|
405 | 405 | 'id' => 'give-donor-primary-email-updated', |
406 | 406 | 'type' => 'updated', |
407 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
407 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
408 | 408 | 'show' => true, |
409 | - ) ); |
|
409 | + )); |
|
410 | 410 | break; |
411 | 411 | |
412 | 412 | case 'primary-email-failed' : |
413 | - Give()->notices->register_notice( array( |
|
413 | + Give()->notices->register_notice(array( |
|
414 | 414 | 'id' => 'give-donor-primary-email-failed', |
415 | 415 | 'type' => 'updated', |
416 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
416 | + 'description' => __('Failed to set primary email.', 'give'), |
|
417 | 417 | 'show' => true, |
418 | - ) ); |
|
418 | + )); |
|
419 | 419 | break; |
420 | 420 | |
421 | 421 | case 'reconnect-user' : |
422 | - Give()->notices->register_notice( array( |
|
422 | + Give()->notices->register_notice(array( |
|
423 | 423 | 'id' => 'give-donor-reconnect-user', |
424 | 424 | 'type' => 'updated', |
425 | - 'description' => __( 'User has been successfully connected with Donor.', 'give' ), |
|
425 | + 'description' => __('User has been successfully connected with Donor.', 'give'), |
|
426 | 426 | 'show' => true, |
427 | - ) ); |
|
427 | + )); |
|
428 | 428 | break; |
429 | 429 | |
430 | 430 | case 'profile-updated' : |
431 | - Give()->notices->register_notice( array( |
|
431 | + Give()->notices->register_notice(array( |
|
432 | 432 | 'id' => 'give-donor-profile-updated', |
433 | 433 | 'type' => 'updated', |
434 | - 'description' => __( 'Donor information updated successfully.', 'give' ), |
|
434 | + 'description' => __('Donor information updated successfully.', 'give'), |
|
435 | 435 | 'show' => true, |
436 | - ) ); |
|
436 | + )); |
|
437 | 437 | break; |
438 | 438 | } |
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
443 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
444 | 444 | |
445 | 445 | |
446 | 446 | /** |
@@ -450,31 +450,30 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return bool |
452 | 452 | */ |
453 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
454 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
455 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
456 | - give_is_test_mode(); |
|
453 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
454 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
455 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
457 | 456 | |
458 | 457 | if ( |
459 | - ! current_user_can( 'view_give_reports' ) || |
|
458 | + ! current_user_can('view_give_reports') || |
|
460 | 459 | ! $is_test_mode |
461 | 460 | ) { |
462 | 461 | return false; |
463 | 462 | } |
464 | 463 | |
465 | 464 | // Add the main site admin menu item. |
466 | - $wp_admin_bar->add_menu( array( |
|
465 | + $wp_admin_bar->add_menu(array( |
|
467 | 466 | 'id' => 'give-test-notice', |
468 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
467 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
469 | 468 | 'parent' => 'top-secondary', |
470 | - 'title' => __( 'Give Test Mode Active', 'give' ), |
|
471 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
472 | - ) ); |
|
469 | + 'title' => __('Give Test Mode Active', 'give'), |
|
470 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
471 | + )); |
|
473 | 472 | |
474 | 473 | return true; |
475 | 474 | } |
476 | 475 | |
477 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
476 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
478 | 477 | |
479 | 478 | /** |
480 | 479 | * Add Link to Import page in from donation archive and donation single page |
@@ -483,12 +482,12 @@ discard block |
||
483 | 482 | */ |
484 | 483 | function give_import_page_link_callback() { |
485 | 484 | ?> |
486 | - <a href="<?php echo esc_url( give_import_page_url() ); ?>" |
|
487 | - class="page-import-action page-title-action"><?php _e( 'Import Donations', 'give' ); ?></a> |
|
485 | + <a href="<?php echo esc_url(give_import_page_url()); ?>" |
|
486 | + class="page-import-action page-title-action"><?php _e('Import Donations', 'give'); ?></a> |
|
488 | 487 | |
489 | 488 | <?php |
490 | 489 | // Check if view donation single page only. |
491 | - if ( ! empty( $_REQUEST['view'] ) && 'view-payment-details' === (string) give_clean( $_REQUEST['view'] ) && 'give-payment-history' === give_clean( $_REQUEST['page'] ) ) { |
|
490 | + if ( ! empty($_REQUEST['view']) && 'view-payment-details' === (string) give_clean($_REQUEST['view']) && 'give-payment-history' === give_clean($_REQUEST['page'])) { |
|
492 | 491 | ?> |
493 | 492 | <style type="text/css"> |
494 | 493 | .wrap #transaction-details-heading { |
@@ -499,7 +498,7 @@ discard block |
||
499 | 498 | } |
500 | 499 | } |
501 | 500 | |
502 | -add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 ); |
|
501 | +add_action('give_payments_page_top', 'give_import_page_link_callback', 11); |
|
503 | 502 | |
504 | 503 | /** |
505 | 504 | * Load donation import ajax callback |
@@ -511,9 +510,9 @@ discard block |
||
511 | 510 | */ |
512 | 511 | function give_donation_import_callback() { |
513 | 512 | $import_setting = array(); |
514 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
513 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
515 | 514 | |
516 | - parse_str( $fields ); |
|
515 | + parse_str($fields); |
|
517 | 516 | |
518 | 517 | $import_setting['create_user'] = $create_user; |
519 | 518 | $import_setting['mode'] = $mode; |
@@ -522,54 +521,54 @@ discard block |
||
522 | 521 | $import_setting['delete_csv'] = $delete_csv; |
523 | 522 | |
524 | 523 | // Parent key id. |
525 | - $main_key = maybe_unserialize( $main_key ); |
|
526 | - |
|
527 | - $current = absint( $_REQUEST['current'] ); |
|
528 | - $total_ajax = absint( $_REQUEST['total_ajax'] ); |
|
529 | - $start = absint( $_REQUEST['start'] ); |
|
530 | - $end = absint( $_REQUEST['end'] ); |
|
531 | - $next = absint( $_REQUEST['next'] ); |
|
532 | - $total = absint( $_REQUEST['total'] ); |
|
533 | - $per_page = absint( $_REQUEST['per_page'] ); |
|
534 | - if ( empty( $delimiter ) ) { |
|
524 | + $main_key = maybe_unserialize($main_key); |
|
525 | + |
|
526 | + $current = absint($_REQUEST['current']); |
|
527 | + $total_ajax = absint($_REQUEST['total_ajax']); |
|
528 | + $start = absint($_REQUEST['start']); |
|
529 | + $end = absint($_REQUEST['end']); |
|
530 | + $next = absint($_REQUEST['next']); |
|
531 | + $total = absint($_REQUEST['total']); |
|
532 | + $per_page = absint($_REQUEST['per_page']); |
|
533 | + if (empty($delimiter)) { |
|
535 | 534 | $delimiter = ','; |
536 | 535 | } |
537 | 536 | |
538 | 537 | // Processing done here. |
539 | - $raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter ); |
|
540 | - $raw_key = maybe_unserialize( $mapto ); |
|
538 | + $raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter); |
|
539 | + $raw_key = maybe_unserialize($mapto); |
|
541 | 540 | |
542 | 541 | // Prevent normal emails. |
543 | - remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
544 | - remove_action( 'give_insert_user', 'give_new_user_notification', 10 ); |
|
545 | - remove_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
542 | + remove_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
543 | + remove_action('give_insert_user', 'give_new_user_notification', 10); |
|
544 | + remove_action('give_insert_payment', 'give_payment_save_page_data'); |
|
546 | 545 | |
547 | - foreach ( $raw_data as $row_data ) { |
|
548 | - give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting ); |
|
546 | + foreach ($raw_data as $row_data) { |
|
547 | + give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting); |
|
549 | 548 | } |
550 | 549 | |
551 | 550 | // Check if function exists or not. |
552 | - if ( function_exists( 'give_payment_save_page_data' ) ) { |
|
553 | - add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
551 | + if (function_exists('give_payment_save_page_data')) { |
|
552 | + add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
554 | 553 | } |
555 | - add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
556 | - add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
554 | + add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
555 | + add_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
557 | 556 | |
558 | - if ( $next == false ) { |
|
557 | + if ($next == false) { |
|
559 | 558 | $json_data = array( |
560 | 559 | 'success' => true, |
561 | - 'message' => __( 'All donation uploaded successfully!', 'give' ), |
|
560 | + 'message' => __('All donation uploaded successfully!', 'give'), |
|
562 | 561 | ); |
563 | 562 | } else { |
564 | 563 | $index_start = $start; |
565 | 564 | $index_end = $end; |
566 | 565 | $last = false; |
567 | 566 | $next = true; |
568 | - if ( $next ) { |
|
567 | + if ($next) { |
|
569 | 568 | $index_start = $index_start + $per_page; |
570 | - $index_end = $per_page + ( $index_start - 1 ); |
|
569 | + $index_end = $per_page + ($index_start - 1); |
|
571 | 570 | } |
572 | - if ( $index_end >= $total ) { |
|
571 | + if ($index_end >= $total) { |
|
573 | 572 | $index_end = $total; |
574 | 573 | $last = true; |
575 | 574 | } |
@@ -583,27 +582,27 @@ discard block |
||
583 | 582 | ); |
584 | 583 | } |
585 | 584 | |
586 | - $url = give_import_page_url( array( |
|
585 | + $url = give_import_page_url(array( |
|
587 | 586 | 'step' => '4', |
588 | 587 | 'importer-type' => 'import_donations', |
589 | 588 | 'csv' => $csv, |
590 | 589 | 'total' => $total, |
591 | 590 | 'delete_csv' => $import_setting['delete_csv'], |
592 | - 'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ), |
|
593 | - ) ); |
|
591 | + 'success' => (isset($json_data['success']) ? $json_data['success'] : ''), |
|
592 | + )); |
|
594 | 593 | $json_data['url'] = $url; |
595 | 594 | |
596 | - $current ++; |
|
595 | + $current++; |
|
597 | 596 | $json_data['current'] = $current; |
598 | 597 | |
599 | - $percentage = ( 100 / ( $total_ajax + 1 ) ) * $current; |
|
598 | + $percentage = (100 / ($total_ajax + 1)) * $current; |
|
600 | 599 | $json_data['percentage'] = $percentage; |
601 | 600 | |
602 | - $json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields ); |
|
603 | - wp_die( json_encode( $json_data ) ); |
|
601 | + $json_data = apply_filters('give_import_ajax_responces', $json_data, $fields); |
|
602 | + wp_die(json_encode($json_data)); |
|
604 | 603 | } |
605 | 604 | |
606 | -add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' ); |
|
605 | +add_action('wp_ajax_give_donation_import', 'give_donation_import_callback'); |
|
607 | 606 | |
608 | 607 | /** |
609 | 608 | * Load core settings import ajax callback |
@@ -615,8 +614,8 @@ discard block |
||
615 | 614 | */ |
616 | 615 | |
617 | 616 | function give_core_settings_import_callback() { |
618 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
619 | - parse_str( $fields, $fields ); |
|
617 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
618 | + parse_str($fields, $fields); |
|
620 | 619 | |
621 | 620 | $json_data['success'] = false; |
622 | 621 | |
@@ -631,22 +630,22 @@ discard block |
||
631 | 630 | * |
632 | 631 | * @return array $fields |
633 | 632 | */ |
634 | - $fields = (array) apply_filters( 'give_import_core_settings_fields', $fields ); |
|
633 | + $fields = (array) apply_filters('give_import_core_settings_fields', $fields); |
|
635 | 634 | |
636 | - $file_name = ( ! empty( $fields['file_name'] ) ? give_clean( $fields['file_name'] ) : false ); |
|
635 | + $file_name = ( ! empty($fields['file_name']) ? give_clean($fields['file_name']) : false); |
|
637 | 636 | |
638 | - if ( ! empty( $file_name ) ) { |
|
639 | - $type = ( ! empty( $fields['type'] ) ? give_clean( $fields['type'] ) : 'merge' ); |
|
637 | + if ( ! empty($file_name)) { |
|
638 | + $type = ( ! empty($fields['type']) ? give_clean($fields['type']) : 'merge'); |
|
640 | 639 | |
641 | 640 | // Get the json data from the file and then alter it in array format |
642 | - $json_string = give_get_core_settings_json( $file_name ); |
|
643 | - $json_to_array = json_decode( $json_string, true ); |
|
641 | + $json_string = give_get_core_settings_json($file_name); |
|
642 | + $json_to_array = json_decode($json_string, true); |
|
644 | 643 | |
645 | 644 | // get the current settign from the options table. |
646 | - $host_give_options = get_option( 'give_settings', array() ); |
|
645 | + $host_give_options = get_option('give_settings', array()); |
|
647 | 646 | |
648 | 647 | // Save old settins for backup. |
649 | - update_option( 'give_settings_old', $host_give_options ); |
|
648 | + update_option('give_settings_old', $host_give_options); |
|
650 | 649 | |
651 | 650 | /** |
652 | 651 | * Filter to Modify Core Settings that are being going to get import in options table as give settings. |
@@ -662,9 +661,9 @@ discard block |
||
662 | 661 | * |
663 | 662 | * @return array $json_to_array Setting that are being going to get imported |
664 | 663 | */ |
665 | - $json_to_array = (array) apply_filters( 'give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields ); |
|
664 | + $json_to_array = (array) apply_filters('give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields); |
|
666 | 665 | |
667 | - update_option( 'give_settings', $json_to_array ); |
|
666 | + update_option('give_settings', $json_to_array); |
|
668 | 667 | |
669 | 668 | $json_data['success'] = true; |
670 | 669 | } |
@@ -680,16 +679,16 @@ discard block |
||
680 | 679 | * |
681 | 680 | * @return array $url |
682 | 681 | */ |
683 | - $json_data['url'] = give_import_page_url( (array) apply_filters( 'give_import_core_settings_success_url', array( |
|
684 | - 'step' => ( empty( $json_data['success'] ) ? '1' : '3' ), |
|
682 | + $json_data['url'] = give_import_page_url((array) apply_filters('give_import_core_settings_success_url', array( |
|
683 | + 'step' => (empty($json_data['success']) ? '1' : '3'), |
|
685 | 684 | 'importer-type' => 'import_core_setting', |
686 | - 'success' => ( empty( $json_data['success'] ) ? '0' : '1' ), |
|
687 | - ) ) ); |
|
685 | + 'success' => (empty($json_data['success']) ? '0' : '1'), |
|
686 | + ))); |
|
688 | 687 | |
689 | - wp_send_json( $json_data ); |
|
688 | + wp_send_json($json_data); |
|
690 | 689 | } |
691 | 690 | |
692 | -add_action( 'wp_ajax_give_core_settings_import', 'give_core_settings_import_callback' ); |
|
691 | +add_action('wp_ajax_give_core_settings_import', 'give_core_settings_import_callback'); |
|
693 | 692 | |
694 | 693 | /** |
695 | 694 | * Initializes blank slate content if a list table is empty. |
@@ -701,7 +700,7 @@ discard block |
||
701 | 700 | $blank_slate->init(); |
702 | 701 | } |
703 | 702 | |
704 | -add_action( 'current_screen', 'give_blank_slate' ); |
|
703 | +add_action('current_screen', 'give_blank_slate'); |
|
705 | 704 | |
706 | 705 | /** |
707 | 706 | * Get Array of WP User Roles. |
@@ -714,8 +713,8 @@ discard block |
||
714 | 713 | $user_roles = array(); |
715 | 714 | |
716 | 715 | // Loop through User Roles. |
717 | - foreach ( get_editable_roles() as $role_name => $role_info ): |
|
718 | - $user_roles[ $role_name ] = $role_info['name']; |
|
716 | + foreach (get_editable_roles() as $role_name => $role_info): |
|
717 | + $user_roles[$role_name] = $role_info['name']; |
|
719 | 718 | endforeach; |
720 | 719 | |
721 | 720 | return $user_roles; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_License' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_License')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_License. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'licenses'; |
30 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
30 | + $this->label = esc_html__('Licenses', 'give'); |
|
31 | 31 | |
32 | 32 | parent::__construct(); |
33 | 33 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * Filter the licenses settings. |
46 | 46 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
47 | 47 | */ |
48 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
48 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Filter the settings. |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param array $settings |
56 | 56 | */ |
57 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
57 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
58 | 58 | |
59 | 59 | // Output. |
60 | 60 | return $settings; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Advanced' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Advanced')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Advanced. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'advanced'; |
30 | - $this->label = __( 'Advanced', 'give' ); |
|
30 | + $this->label = __('Advanced', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'advanced-options'; |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $current_section = give_get_current_setting_section(); |
47 | 47 | |
48 | - switch ( $current_section ) { |
|
48 | + switch ($current_section) { |
|
49 | 49 | case 'advanced-options': |
50 | 50 | $settings = array( |
51 | 51 | array( |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | 'type' => 'title', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => __( 'Default User Role', 'give' ), |
|
57 | - 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ), |
|
56 | + 'name' => __('Default User Role', 'give'), |
|
57 | + 'desc' => __('Assign default user roles for donors when donors opt to register as a WP User.', 'give'), |
|
58 | 58 | 'id' => 'donor_default_user_role', |
59 | 59 | 'type' => 'select', |
60 | 60 | 'default' => 'give_donor', |
@@ -62,55 +62,55 @@ discard block |
||
62 | 62 | ), |
63 | 63 | array( |
64 | 64 | /* translators: %s: the_content */ |
65 | - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
|
65 | + 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'), |
|
66 | 66 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
67 | - '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>' ), |
|
67 | + '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>'), |
|
68 | 68 | 'id' => 'the_content_filter', |
69 | 69 | 'default' => 'enabled', |
70 | 70 | 'type' => 'radio_inline', |
71 | 71 | 'options' => array( |
72 | - 'enabled' => __( 'Enabled', 'give' ), |
|
73 | - 'disabled' => __( 'Disabled', 'give' ), |
|
72 | + 'enabled' => __('Enabled', 'give'), |
|
73 | + 'disabled' => __('Disabled', 'give'), |
|
74 | 74 | ), |
75 | 75 | ), |
76 | 76 | array( |
77 | - 'name' => __( 'Script Loading Location', 'give' ), |
|
78 | - 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
|
77 | + 'name' => __('Script Loading Location', 'give'), |
|
78 | + 'desc' => __('This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give'), |
|
79 | 79 | 'id' => 'scripts_footer', |
80 | 80 | 'type' => 'radio_inline', |
81 | 81 | 'default' => 'disabled', |
82 | 82 | 'options' => array( |
83 | - 'disabled' => __( 'Head', 'give' ), |
|
84 | - 'enabled' => __( 'Footer', 'give' ), |
|
83 | + 'disabled' => __('Head', 'give'), |
|
84 | + 'enabled' => __('Footer', 'give'), |
|
85 | 85 | ), |
86 | 86 | ), |
87 | 87 | array( |
88 | - 'name' => __( 'Akismet SPAM Protection', 'give' ), |
|
89 | - 'desc' => __( 'Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give' ), |
|
88 | + 'name' => __('Akismet SPAM Protection', 'give'), |
|
89 | + 'desc' => __('Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give'), |
|
90 | 90 | 'id' => 'akismet_spam_protection', |
91 | 91 | 'type' => 'radio_inline', |
92 | - 'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled', |
|
92 | + 'default' => (give_check_akismet_key()) ? 'enabled' : 'disabled', |
|
93 | 93 | 'options' => array( |
94 | - 'enabled' => __( 'Enabled', 'give' ), |
|
95 | - 'disabled' => __( 'Disabled', 'give' ), |
|
94 | + 'enabled' => __('Enabled', 'give'), |
|
95 | + 'disabled' => __('Disabled', 'give'), |
|
96 | 96 | ), |
97 | 97 | ), |
98 | 98 | array( |
99 | - 'name' => __( 'Remove Data on Uninstall', 'give' ), |
|
100 | - 'desc' => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
|
99 | + 'name' => __('Remove Data on Uninstall', 'give'), |
|
100 | + 'desc' => __('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'), |
|
101 | 101 | 'id' => 'uninstall_on_delete', |
102 | 102 | 'type' => 'radio_inline', |
103 | 103 | 'default' => 'disabled', |
104 | 104 | 'options' => array( |
105 | - 'enabled' => __( 'Yes, Remove all data', 'give' ), |
|
106 | - 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ), |
|
105 | + 'enabled' => __('Yes, Remove all data', 'give'), |
|
106 | + 'disabled' => __('No, keep my Give settings and donation data', 'give'), |
|
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | array( |
110 | - 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
110 | + 'name' => __('Advanced Settings Docs Link', 'give'), |
|
111 | 111 | 'id' => 'advanced_settings_docs_link', |
112 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
113 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
112 | + 'url' => esc_url('http://docs.givewp.com/settings-advanced'), |
|
113 | + 'title' => __('Advanced Settings', 'give'), |
|
114 | 114 | 'type' => 'give_docs_link', |
115 | 115 | ), |
116 | 116 | array( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * Filter the advanced settings. |
127 | 127 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
128 | 128 | */ |
129 | - $settings = apply_filters( 'give_settings_advanced', $settings ); |
|
129 | + $settings = apply_filters('give_settings_advanced', $settings); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Filter the settings. |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $settings |
137 | 137 | */ |
138 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
138 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
139 | 139 | |
140 | 140 | // Output. |
141 | 141 | return $settings; |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function get_sections() { |
151 | 151 | $sections = array( |
152 | - 'advanced-options' => __( 'Advanced Options', 'give' ), |
|
152 | + 'advanced-options' => __('Advanced Options', 'give'), |
|
153 | 153 | ); |
154 | 154 | |
155 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
155 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Display' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Display')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Display. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'display'; |
30 | - $this->label = __( 'Display Options', 'give' ); |
|
30 | + $this->label = __('Display Options', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'display-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'display-settings' : |
49 | 49 | $settings = array( |
50 | 50 | // Section 1: Display |
@@ -53,55 +53,55 @@ discard block |
||
53 | 53 | 'type' => 'title', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => __( 'Default Give Styles', 'give' ), |
|
57 | - 'desc' => __( 'You can disable Give\'s default styles for donation forms and other frontend elements.', 'give' ), |
|
56 | + 'name' => __('Default Give Styles', 'give'), |
|
57 | + 'desc' => __('You can disable Give\'s default styles for donation forms and other frontend elements.', 'give'), |
|
58 | 58 | 'id' => 'css', |
59 | 59 | 'type' => 'radio_inline', |
60 | 60 | 'default' => 'enabled', |
61 | 61 | 'options' => array( |
62 | - 'enabled' => __( 'Enabled', 'give' ), |
|
63 | - 'disabled' => __( 'Disabled', 'give' ), |
|
62 | + 'enabled' => __('Enabled', 'give'), |
|
63 | + 'disabled' => __('Disabled', 'give'), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'Floating Labels', 'give' ), |
|
67 | + 'name' => __('Floating Labels', 'give'), |
|
68 | 68 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
69 | - 'desc' => sprintf( wp_kses( __( '<a href="%s" target="_blank">Floating labels</a> allows your labels to be inset within the form fields to provide a cleaner form appearance. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array( |
|
69 | + 'desc' => sprintf(wp_kses(__('<a href="%s" target="_blank">Floating labels</a> allows your labels to be inset within the form fields to provide a cleaner form appearance. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array( |
|
70 | 70 | 'a' => array( |
71 | 71 | 'href' => array(), |
72 | 72 | 'target' => array(), |
73 | 73 | ), |
74 | - ) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
74 | + )), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
75 | 75 | 'id' => 'floatlabels', |
76 | 76 | 'type' => 'radio_inline', |
77 | 77 | 'default' => 'disabled', |
78 | 78 | 'options' => array( |
79 | - 'enabled' => __( 'Enabled', 'give' ), |
|
80 | - 'disabled' => __( 'Disabled', 'give' ), |
|
79 | + 'enabled' => __('Enabled', 'give'), |
|
80 | + 'disabled' => __('Disabled', 'give'), |
|
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | array( |
84 | - 'name' => __( 'Welcome Screen', 'give' ), |
|
84 | + 'name' => __('Welcome Screen', 'give'), |
|
85 | 85 | /* translators: %s: about page URL */ |
86 | - 'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that displays each time Give is activated or updated.', 'give' ), array( |
|
86 | + 'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that displays each time Give is activated or updated.', 'give'), array( |
|
87 | 87 | 'a' => array( |
88 | 88 | 'href' => array(), |
89 | 89 | 'target' => array(), |
90 | 90 | ), |
91 | - ) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ), |
|
91 | + )), esc_url(admin_url('index.php?page=give-about'))), |
|
92 | 92 | 'id' => 'welcome', |
93 | 93 | 'type' => 'radio_inline', |
94 | 94 | 'default' => 'enabled', |
95 | 95 | 'options' => array( |
96 | - 'enabled' => __( 'Enabled', 'give' ), |
|
97 | - 'disabled' => __( 'Disabled', 'give' ), |
|
96 | + 'enabled' => __('Enabled', 'give'), |
|
97 | + 'disabled' => __('Disabled', 'give'), |
|
98 | 98 | ), |
99 | 99 | ), |
100 | 100 | array( |
101 | - 'name' => __( 'Display Settings Docs Link', 'give' ), |
|
101 | + 'name' => __('Display Settings Docs Link', 'give'), |
|
102 | 102 | 'id' => 'display_settings_docs_link', |
103 | - 'url' => esc_url( 'http://docs.givewp.com/form-display-options' ), |
|
104 | - 'title' => __( 'Display Options Settings', 'give' ), |
|
103 | + 'url' => esc_url('http://docs.givewp.com/form-display-options'), |
|
104 | + 'title' => __('Display Options Settings', 'give'), |
|
105 | 105 | 'type' => 'give_docs_link', |
106 | 106 | ), |
107 | 107 | array( |
@@ -118,78 +118,78 @@ discard block |
||
118 | 118 | 'type' => 'title', |
119 | 119 | ), |
120 | 120 | array( |
121 | - 'name' => __( 'Form Single Views', 'give' ), |
|
122 | - 'desc' => __( 'By default, all donation form have single views enabled which creates a specific URL on your website for that form. This option disables the singular posts from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
121 | + 'name' => __('Form Single Views', 'give'), |
|
122 | + 'desc' => __('By default, all donation form have single views enabled which creates a specific URL on your website for that form. This option disables the singular posts from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
123 | 123 | 'id' => 'forms_singular', |
124 | 124 | 'type' => 'radio_inline', |
125 | 125 | 'default' => 'enabled', |
126 | 126 | 'options' => array( |
127 | - 'enabled' => __( 'Enabled', 'give' ), |
|
128 | - 'disabled' => __( 'Disabled', 'give' ), |
|
127 | + 'enabled' => __('Enabled', 'give'), |
|
128 | + 'disabled' => __('Disabled', 'give'), |
|
129 | 129 | ), |
130 | 130 | ), |
131 | 131 | array( |
132 | - 'name' => __( 'Form Archives', 'give' ), |
|
133 | - 'desc' => sprintf( wp_kses( __( 'Archives pages list all the donation 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 <a href="%s">refresh your permalinks</a> after this option has been enabled.', 'give' ), array( |
|
132 | + 'name' => __('Form Archives', 'give'), |
|
133 | + 'desc' => sprintf(wp_kses(__('Archives pages list all the donation 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 <a href="%s">refresh your permalinks</a> after this option has been enabled.', 'give'), array( |
|
134 | 134 | 'a' => array( |
135 | 135 | 'href' => array(), |
136 | 136 | 'target' => array(), |
137 | 137 | ), |
138 | - ) ), esc_url( admin_url( 'options-permalink.php' ) ) ), |
|
138 | + )), esc_url(admin_url('options-permalink.php'))), |
|
139 | 139 | 'id' => 'forms_archives', |
140 | 140 | 'type' => 'radio_inline', |
141 | 141 | 'default' => 'enabled', |
142 | 142 | 'options' => array( |
143 | - 'enabled' => __( 'Enabled', 'give' ), |
|
144 | - 'disabled' => __( 'Disabled', 'give' ), |
|
143 | + 'enabled' => __('Enabled', 'give'), |
|
144 | + 'disabled' => __('Disabled', 'give'), |
|
145 | 145 | ), |
146 | 146 | ), |
147 | 147 | array( |
148 | - 'name' => __( 'Form Excerpts', 'give' ), |
|
149 | - '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' ), |
|
148 | + 'name' => __('Form Excerpts', 'give'), |
|
149 | + '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'), |
|
150 | 150 | 'id' => 'forms_excerpt', |
151 | 151 | 'type' => 'radio_inline', |
152 | 152 | 'default' => 'enabled', |
153 | 153 | 'options' => array( |
154 | - 'enabled' => __( 'Enabled', 'give' ), |
|
155 | - 'disabled' => __( 'Disabled', 'give' ), |
|
154 | + 'enabled' => __('Enabled', 'give'), |
|
155 | + 'disabled' => __('Disabled', 'give'), |
|
156 | 156 | ), |
157 | 157 | ), |
158 | 158 | array( |
159 | - 'name' => __( 'Form Featured Image', 'give' ), |
|
160 | - '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' ), |
|
159 | + 'name' => __('Form Featured Image', 'give'), |
|
160 | + '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'), |
|
161 | 161 | 'id' => 'form_featured_img', |
162 | 162 | 'type' => 'radio_inline', |
163 | 163 | 'default' => 'enabled', |
164 | 164 | 'options' => array( |
165 | - 'enabled' => __( 'Enabled', 'give' ), |
|
166 | - 'disabled' => __( 'Disabled', 'give' ), |
|
165 | + 'enabled' => __('Enabled', 'give'), |
|
166 | + 'disabled' => __('Disabled', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | array( |
170 | - 'name' => __( 'Featured Image Size', 'give' ), |
|
171 | - '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 form\'s featured image.', 'give' ), |
|
170 | + 'name' => __('Featured Image Size', 'give'), |
|
171 | + '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 form\'s featured image.', 'give'), |
|
172 | 172 | 'id' => 'featured_image_size', |
173 | 173 | 'type' => 'select', |
174 | 174 | 'default' => 'large', |
175 | 175 | 'options' => give_get_featured_image_sizes(), |
176 | 176 | ), |
177 | 177 | array( |
178 | - 'name' => __( 'Single Form Sidebar', 'give' ), |
|
179 | - 'desc' => __( 'The sidebar allows you to add additional widgets to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
178 | + 'name' => __('Single Form Sidebar', 'give'), |
|
179 | + 'desc' => __('The sidebar allows you to add additional widgets to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
180 | 180 | 'id' => 'form_sidebar', |
181 | 181 | 'type' => 'radio_inline', |
182 | 182 | 'default' => 'enabled', |
183 | 183 | 'options' => array( |
184 | - 'enabled' => __( 'Enabled', 'give' ), |
|
185 | - 'disabled' => __( 'Disabled', 'give' ), |
|
184 | + 'enabled' => __('Enabled', 'give'), |
|
185 | + 'disabled' => __('Disabled', 'give'), |
|
186 | 186 | ), |
187 | 187 | ), |
188 | 188 | array( |
189 | - 'name' => __( 'Post Types Docs Link', 'give' ), |
|
189 | + 'name' => __('Post Types Docs Link', 'give'), |
|
190 | 190 | 'id' => 'post_types_settings_docs_link', |
191 | - 'url' => esc_url( 'http://docs.givewp.com/settings-post-types' ), |
|
192 | - 'title' => __( 'Post Types Settings', 'give' ), |
|
191 | + 'url' => esc_url('http://docs.givewp.com/settings-post-types'), |
|
192 | + 'title' => __('Post Types Settings', 'give'), |
|
193 | 193 | 'type' => 'give_docs_link', |
194 | 194 | ), |
195 | 195 | array( |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | 'type' => 'title', |
207 | 207 | ), |
208 | 208 | array( |
209 | - 'name' => __( 'Form Categories', 'give' ), |
|
210 | - 'desc' => __( 'Enable Categories for all Give forms.', 'give' ), |
|
209 | + 'name' => __('Form Categories', 'give'), |
|
210 | + 'desc' => __('Enable Categories for all Give forms.', 'give'), |
|
211 | 211 | 'id' => 'categories', |
212 | 212 | 'type' => 'radio_inline', |
213 | 213 | 'default' => 'disabled', |
214 | 214 | 'options' => array( |
215 | - 'enabled' => __( 'Enabled', 'give' ), |
|
216 | - 'disabled' => __( 'Disabled', 'give' ), |
|
215 | + 'enabled' => __('Enabled', 'give'), |
|
216 | + 'disabled' => __('Disabled', 'give'), |
|
217 | 217 | ), |
218 | 218 | ), |
219 | 219 | array( |
220 | - 'name' => __( 'Form Tags', 'give' ), |
|
221 | - 'desc' => __( 'Enable Tags for all Give forms.', 'give' ), |
|
220 | + 'name' => __('Form Tags', 'give'), |
|
221 | + 'desc' => __('Enable Tags for all Give forms.', 'give'), |
|
222 | 222 | 'id' => 'tags', |
223 | 223 | 'type' => 'radio_inline', |
224 | 224 | 'default' => 'disabled', |
225 | 225 | 'options' => array( |
226 | - 'enabled' => __( 'Enabled', 'give' ), |
|
227 | - 'disabled' => __( 'Disabled', 'give' ), |
|
226 | + 'enabled' => __('Enabled', 'give'), |
|
227 | + 'disabled' => __('Disabled', 'give'), |
|
228 | 228 | ), |
229 | 229 | ), |
230 | 230 | array( |
231 | - 'name' => __( 'Taxonomies Docs Link', 'give' ), |
|
231 | + 'name' => __('Taxonomies Docs Link', 'give'), |
|
232 | 232 | 'id' => 'taxonomies_settings_docs_link', |
233 | - 'url' => esc_url( 'http://docs.givewp.com/settings-taxonomies' ), |
|
234 | - 'title' => __( 'Taxonomies Settings', 'give' ), |
|
233 | + 'url' => esc_url('http://docs.givewp.com/settings-taxonomies'), |
|
234 | + 'title' => __('Taxonomies Settings', 'give'), |
|
235 | 235 | 'type' => 'give_docs_link', |
236 | 236 | ), |
237 | 237 | array( |
@@ -248,36 +248,36 @@ discard block |
||
248 | 248 | 'type' => 'title', |
249 | 249 | ), |
250 | 250 | array( |
251 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
252 | - 'desc' => __( 'Would you like donors to require that donors agree to your terms when donating? Note: You can enable/disable this option and customize the terms per form as well.', 'give' ), |
|
251 | + 'name' => __('Terms and Conditions', 'give'), |
|
252 | + 'desc' => __('Would you like donors to require that donors agree to your terms when donating? Note: You can enable/disable this option and customize the terms per form as well.', 'give'), |
|
253 | 253 | 'id' => 'terms', |
254 | 254 | 'type' => 'radio_inline', |
255 | 255 | 'default' => 'disabled', |
256 | 256 | 'options' => array( |
257 | - 'enabled' => __( 'Enabled', 'give' ), |
|
258 | - 'disabled' => __( 'Disabled', 'give' ), |
|
257 | + 'enabled' => __('Enabled', 'give'), |
|
258 | + 'disabled' => __('Disabled', 'give'), |
|
259 | 259 | ), |
260 | 260 | ), |
261 | 261 | array( |
262 | - 'name' => __( 'Agree to Terms Label', 'give' ), |
|
263 | - 'desc' => __( 'The label shown next to the agree to terms check box. Customize it here or leave blank to use the default placeholder text. Note: You can customize the label per form.', 'give' ), |
|
262 | + 'name' => __('Agree to Terms Label', 'give'), |
|
263 | + 'desc' => __('The label shown next to the agree to terms check box. Customize it here or leave blank to use the default placeholder text. Note: You can customize the label per form.', 'give'), |
|
264 | 264 | 'id' => 'agree_to_terms_label', |
265 | 265 | 'attributes' => array( |
266 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
266 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
267 | 267 | ), |
268 | 268 | 'type' => 'text', |
269 | 269 | ), |
270 | 270 | array( |
271 | - 'name' => __( 'Agreement Text', 'give' ), |
|
272 | - 'desc' => __( 'This is the actual text which the user will be asked to agree to in order to donate. Note: You can customize the content per form as needed.', 'give' ), |
|
271 | + 'name' => __('Agreement Text', 'give'), |
|
272 | + 'desc' => __('This is the actual text which the user will be asked to agree to in order to donate. Note: You can customize the content per form as needed.', 'give'), |
|
273 | 273 | 'id' => 'agreement_text', |
274 | 274 | 'type' => 'wysiwyg', |
275 | 275 | ), |
276 | 276 | array( |
277 | - 'name' => __( 'Terms and Conditions Docs Link', 'give' ), |
|
277 | + 'name' => __('Terms and Conditions Docs Link', 'give'), |
|
278 | 278 | 'id' => 'terms_settings_docs_link', |
279 | - 'url' => esc_url( 'http://docs.givewp.com/settings-terms' ), |
|
280 | - 'title' => __( 'Terms and Conditions Settings', 'give' ), |
|
279 | + 'url' => esc_url('http://docs.givewp.com/settings-terms'), |
|
280 | + 'title' => __('Terms and Conditions Settings', 'give'), |
|
281 | 281 | 'type' => 'give_docs_link', |
282 | 282 | ), |
283 | 283 | array( |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * Filter the display options settings. |
293 | 293 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
294 | 294 | */ |
295 | - $settings = apply_filters( 'give_settings_display', $settings ); |
|
295 | + $settings = apply_filters('give_settings_display', $settings); |
|
296 | 296 | |
297 | 297 | /** |
298 | 298 | * Filter the settings. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @param array $settings |
303 | 303 | */ |
304 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
304 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
305 | 305 | |
306 | 306 | // Output. |
307 | 307 | return $settings; |
@@ -315,13 +315,13 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get_sections() { |
317 | 317 | $sections = array( |
318 | - 'display-settings' => __( 'Display', 'give' ), |
|
319 | - 'post-types' => __( 'Post Types', 'give' ), |
|
320 | - 'taxonomies' => __( 'Taxonomies', 'give' ), |
|
321 | - 'term-and-conditions' => __( 'Terms and Conditions', 'give' ), |
|
318 | + 'display-settings' => __('Display', 'give'), |
|
319 | + 'post-types' => __('Post Types', 'give'), |
|
320 | + 'taxonomies' => __('Taxonomies', 'give'), |
|
321 | + 'term-and-conditions' => __('Terms and Conditions', 'give'), |
|
322 | 322 | ); |
323 | 323 | |
324 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
324 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! class_exists( 'Give_CMB2_Settings_Loader' ) ) : |
|
12 | +if ( ! class_exists('Give_CMB2_Settings_Loader')) : |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * This class loads the cmb2 settings. |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | |
53 | 53 | // Get current tab. |
54 | 54 | $this->current_tab = give_get_current_setting_tab(); |
55 | - $this->current_section = empty( $_REQUEST['section'] ) ? ( current( array_keys( $this->get_sections() ) ) ) : sanitize_title( $_REQUEST['section'] ); |
|
55 | + $this->current_section = empty($_REQUEST['section']) ? (current(array_keys($this->get_sections()))) : sanitize_title($_REQUEST['section']); |
|
56 | 56 | |
57 | 57 | // Tab ID. |
58 | 58 | $this->id = $this->current_tab; |
59 | 59 | |
60 | 60 | // Add addon tabs. |
61 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_addon_settings_page' ), 999999 ); |
|
61 | + add_filter('give-settings_tabs_array', array($this, 'add_addon_settings_page'), 999999); |
|
62 | 62 | |
63 | 63 | // Add save hook to addons. |
64 | - add_action( 'give-settings_get_settings_pages', array( $this, 'setup_addon_save_hook' ), 999999 ); |
|
64 | + add_action('give-settings_get_settings_pages', array($this, 'setup_addon_save_hook'), 999999); |
|
65 | 65 | |
66 | 66 | // Add backward compatibility filters plugin settings. |
67 | - $setting_tabs = array( 'general', 'gateways', 'display', 'emails', 'addons', 'licenses' ); |
|
67 | + $setting_tabs = array('general', 'gateways', 'display', 'emails', 'addons', 'licenses'); |
|
68 | 68 | |
69 | 69 | // Filter Payment Gateways settings. |
70 | - if ( in_array( $this->current_tab, $setting_tabs ) ) { |
|
71 | - add_filter( "give_get_settings_{$this->current_tab}", array( |
|
70 | + if (in_array($this->current_tab, $setting_tabs)) { |
|
71 | + add_filter("give_get_settings_{$this->current_tab}", array( |
|
72 | 72 | $this, |
73 | 73 | 'get_filtered_addon_settings', |
74 | - ), 999999, 1 ); |
|
75 | - add_filter( "give_get_sections_{$this->current_tab}", array( |
|
74 | + ), 999999, 1); |
|
75 | + add_filter("give_get_sections_{$this->current_tab}", array( |
|
76 | 76 | $this, |
77 | 77 | 'get_filtered_addon_sections', |
78 | - ), 999999, 1 ); |
|
78 | + ), 999999, 1); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - function set_default_setting_tab( $setting_tab ) { |
|
91 | + function set_default_setting_tab($setting_tab) { |
|
92 | 92 | $default_tab = ''; |
93 | 93 | |
94 | 94 | // Set default tab to first setting tab. |
95 | - if ( $sections = array_keys( $this->get_sections() ) ) { |
|
96 | - $default_tab = current( $sections ); |
|
95 | + if ($sections = array_keys($this->get_sections())) { |
|
96 | + $default_tab = current($sections); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $default_tab; |
@@ -108,29 +108,29 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return mixed |
110 | 110 | */ |
111 | - function add_addon_settings_page( $pages ) { |
|
111 | + function add_addon_settings_page($pages) { |
|
112 | 112 | // Previous setting page. |
113 | 113 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
114 | 114 | |
115 | 115 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
116 | - unset( $previous_pages['api'] ); |
|
117 | - unset( $previous_pages['system_info'] ); |
|
116 | + unset($previous_pages['api']); |
|
117 | + unset($previous_pages['system_info']); |
|
118 | 118 | |
119 | 119 | // Tab is not register. |
120 | - $pages_diff = array_keys( array_diff( $previous_pages, $pages ) ); |
|
120 | + $pages_diff = array_keys(array_diff($previous_pages, $pages)); |
|
121 | 121 | |
122 | 122 | // Merge old settings with new settings. |
123 | - $pages = array_merge( $pages, $previous_pages ); |
|
123 | + $pages = array_merge($pages, $previous_pages); |
|
124 | 124 | |
125 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
125 | + if (in_array($this->current_tab, $pages_diff)) { |
|
126 | 126 | // Filter & actions. |
127 | - add_filter( "give_default_setting_tab_section_{$this->current_tab}", array( |
|
127 | + add_filter("give_default_setting_tab_section_{$this->current_tab}", array( |
|
128 | 128 | $this, |
129 | 129 | 'set_default_setting_tab', |
130 | - ), 10 ); |
|
131 | - add_action( "give-settings_sections_{$this->current_tab}_page", array( $this, 'output_sections' ) ); |
|
132 | - add_action( "give-settings_settings_{$this->current_tab}_page", array( $this, 'output' ), 10 ); |
|
133 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
130 | + ), 10); |
|
131 | + add_action("give-settings_sections_{$this->current_tab}_page", array($this, 'output_sections')); |
|
132 | + add_action("give-settings_settings_{$this->current_tab}_page", array($this, 'output'), 10); |
|
133 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return $pages; |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return mixed |
148 | 148 | */ |
149 | - function setup_addon_save_hook( $pages ) { |
|
149 | + function setup_addon_save_hook($pages) { |
|
150 | 150 | $page_ids = array(); |
151 | 151 | |
152 | - foreach ( $pages as $page ) { |
|
153 | - $page_ids = $page->add_settings_page( $page_ids ); |
|
152 | + foreach ($pages as $page) { |
|
153 | + $page_ids = $page->add_settings_page($page_ids); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Previous setting page. |
157 | 157 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
158 | 158 | |
159 | 159 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
160 | - unset( $previous_pages['api'] ); |
|
161 | - unset( $previous_pages['system_info'] ); |
|
160 | + unset($previous_pages['api']); |
|
161 | + unset($previous_pages['system_info']); |
|
162 | 162 | |
163 | 163 | // Tab is not register. |
164 | - $pages_diff = array_keys( array_diff( $previous_pages, $page_ids ) ); |
|
164 | + $pages_diff = array_keys(array_diff($previous_pages, $page_ids)); |
|
165 | 165 | |
166 | 166 | // Merge old settings with new settings. |
167 | 167 | // $pages = array_merge( $page_ids, $previous_pages ); |
168 | 168 | |
169 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
169 | + if (in_array($this->current_tab, $pages_diff)) { |
|
170 | 170 | // Filter & actions. |
171 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
171 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $pages; |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - function get_section_name( $field_name ) { |
|
186 | + function get_section_name($field_name) { |
|
187 | 187 | // Bailout. |
188 | - if ( empty( $field_name ) ) { |
|
188 | + if (empty($field_name)) { |
|
189 | 189 | return $field_name; |
190 | 190 | } |
191 | 191 | |
192 | - $section_name = explode( ' ', $field_name ); |
|
192 | + $section_name = explode(' ', $field_name); |
|
193 | 193 | |
194 | 194 | // Output. |
195 | - return strip_tags( implode( ' ', $section_name ) ); |
|
195 | + return strip_tags(implode(' ', $section_name)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function en_translation( $translation, $text ) { |
|
210 | + public function en_translation($translation, $text) { |
|
211 | 211 | return $text; |
212 | 212 | } |
213 | 213 | |
@@ -221,52 +221,52 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return mixed |
223 | 223 | */ |
224 | - function get_filtered_addon_sections( $sections = array() ) { |
|
224 | + function get_filtered_addon_sections($sections = array()) { |
|
225 | 225 | // New sections. |
226 | 226 | $new_sections = array(); |
227 | - $sections_ID = array_keys( $sections ); |
|
228 | - $setting_fields = $this->prev_settings->give_settings( $this->current_tab ); |
|
227 | + $sections_ID = array_keys($sections); |
|
228 | + $setting_fields = $this->prev_settings->give_settings($this->current_tab); |
|
229 | 229 | |
230 | 230 | // We need untranslated settings for backward compatibility. |
231 | - add_filter( 'gettext', array( $this, 'en_translation' ), 10, 2 ); |
|
232 | - $en_setting_fields = $this->prev_settings->give_settings( $this->current_tab ); |
|
233 | - remove_filter( 'gettext', array( $this, 'en_translation' ), 10, 2 ); |
|
231 | + add_filter('gettext', array($this, 'en_translation'), 10, 2); |
|
232 | + $en_setting_fields = $this->prev_settings->give_settings($this->current_tab); |
|
233 | + remove_filter('gettext', array($this, 'en_translation'), 10, 2); |
|
234 | 234 | |
235 | - if ( ! empty( $setting_fields ) && ! empty( $setting_fields['fields'] ) ) { |
|
235 | + if ( ! empty($setting_fields) && ! empty($setting_fields['fields'])) { |
|
236 | 236 | |
237 | - foreach ( $setting_fields['fields'] as $index => $field ) { |
|
237 | + foreach ($setting_fields['fields'] as $index => $field) { |
|
238 | 238 | // Collect new sections from addons. |
239 | - if ( 'give_title' !== $field['type'] ) { |
|
239 | + if ('give_title' !== $field['type']) { |
|
240 | 240 | continue; |
241 | 241 | } |
242 | 242 | |
243 | 243 | // Untranslated setting name. |
244 | - $en_setting_field_name = isset( $en_setting_fields['fields'][ $index ]['name'] ) ? $en_setting_fields['fields'][ $index ]['name'] : ''; |
|
244 | + $en_setting_field_name = isset($en_setting_fields['fields'][$index]['name']) ? $en_setting_fields['fields'][$index]['name'] : ''; |
|
245 | 245 | |
246 | 246 | // Section name. |
247 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : ''; |
|
248 | - $section_name = $this->get_section_name( $field['name'] ); |
|
247 | + $field['name'] = isset($field['name']) ? $field['name'] : ''; |
|
248 | + $section_name = $this->get_section_name($field['name']); |
|
249 | 249 | |
250 | 250 | // Check if section name exit and section title array is not empty. |
251 | - if ( ! empty( $sections ) && ! empty( $en_setting_field_name ) ) { |
|
251 | + if ( ! empty($sections) && ! empty($en_setting_field_name)) { |
|
252 | 252 | |
253 | 253 | // Bailout: Do not load section if it is already exist. |
254 | 254 | if ( |
255 | - in_array( sanitize_title( $en_setting_field_name ), $sections_ID ) // Check section id. |
|
256 | - || in_array( $section_name, $sections ) // Check section name. |
|
255 | + in_array(sanitize_title($en_setting_field_name), $sections_ID) // Check section id. |
|
256 | + || in_array($section_name, $sections) // Check section name. |
|
257 | 257 | ) { |
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | // Collect new sections from addons. |
263 | - $new_sections[ sanitize_title( $field['name'] ) ] = $section_name; |
|
263 | + $new_sections[sanitize_title($field['name'])] = $section_name; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Add new section. |
268 | - if ( ! empty( $new_sections ) ) { |
|
269 | - $sections = array_merge( $sections, $new_sections ); |
|
268 | + if ( ! empty($new_sections)) { |
|
269 | + $sections = array_merge($sections, $new_sections); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | // Output. |
@@ -284,19 +284,19 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - function get_filtered_addon_settings( $settings, $setting_fields = array() ) { |
|
287 | + function get_filtered_addon_settings($settings, $setting_fields = array()) { |
|
288 | 288 | global $wp_filter; |
289 | 289 | |
290 | 290 | $new_setting_fields = array(); |
291 | 291 | |
292 | - if ( ! empty( $settings ) ) { |
|
292 | + if ( ! empty($settings)) { |
|
293 | 293 | // Bailout: If setting array contain first element of type title then it means it is already created with new setting api (skip this section ). |
294 | - if ( isset( $settings[0]['type'] ) && 'title' == $settings[0]['type'] ) { |
|
295 | - foreach ( $settings as $setting ) { |
|
294 | + if (isset($settings[0]['type']) && 'title' == $settings[0]['type']) { |
|
295 | + foreach ($settings as $setting) { |
|
296 | 296 | $new_setting_fields[] = $setting; |
297 | 297 | |
298 | 298 | // We need setting only till first section end. |
299 | - if ( 'sectionend' === $setting['type'] ) { |
|
299 | + if ('sectionend' === $setting['type']) { |
|
300 | 300 | break; |
301 | 301 | } |
302 | 302 | } |
@@ -308,24 +308,24 @@ discard block |
||
308 | 308 | $prev_title_field_id = ''; |
309 | 309 | |
310 | 310 | // Create new setting fields. |
311 | - foreach ( $settings as $index => $field ) { |
|
311 | + foreach ($settings as $index => $field) { |
|
312 | 312 | |
313 | 313 | // Bailout: Must need field type to process. |
314 | - if ( ! isset( $field['type'] ) ) { |
|
314 | + if ( ! isset($field['type'])) { |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Set wrapper class if any. |
319 | - if ( ! empty( $field['row_classes'] ) ) { |
|
319 | + if ( ! empty($field['row_classes'])) { |
|
320 | 320 | $field['wrapper_class'] = $field['row_classes']; |
321 | - unset( $field['row_classes'] ); |
|
321 | + unset($field['row_classes']); |
|
322 | 322 | } |
323 | 323 | |
324 | - $field['name'] = ! isset( $field['name'] ) ? '' : $field['name']; |
|
325 | - $field['desc'] = ! isset( $field['desc'] ) ? '' : $field['desc']; |
|
324 | + $field['name'] = ! isset($field['name']) ? '' : $field['name']; |
|
325 | + $field['desc'] = ! isset($field['desc']) ? '' : $field['desc']; |
|
326 | 326 | |
327 | 327 | // Modify cmb2 setting fields. |
328 | - switch ( $field['type'] ) { |
|
328 | + switch ($field['type']) { |
|
329 | 329 | case 'text' : |
330 | 330 | case 'file' : |
331 | 331 | $field['css'] = 'width:25em;'; |
@@ -349,18 +349,18 @@ discard block |
||
349 | 349 | $field['type'] = 'title'; |
350 | 350 | |
351 | 351 | // Since we are showing sections, so there now ned to show horizontal rules. |
352 | - if ( '<hr>' === $field['desc'] ) { |
|
352 | + if ('<hr>' === $field['desc']) { |
|
353 | 353 | $field['desc'] = ''; |
354 | 354 | } |
355 | 355 | |
356 | 356 | break; |
357 | 357 | } |
358 | 358 | |
359 | - if ( 'title' === $field['type'] ) { |
|
359 | + if ('title' === $field['type']) { |
|
360 | 360 | |
361 | 361 | // If we do not have first element as title then these field will be skip from frontend |
362 | 362 | // because there are not belong to any section, so put all abandon fields under first section. |
363 | - if ( $index && empty( $prev_title_field_id ) ) { |
|
363 | + if ($index && empty($prev_title_field_id)) { |
|
364 | 364 | array_unshift( |
365 | 365 | $new_setting_fields, |
366 | 366 | array( |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $prev_title_field_id = $field['id']; |
375 | 375 | |
376 | 376 | continue; |
377 | - } elseif ( $index ) { |
|
377 | + } elseif ($index) { |
|
378 | 378 | // Section end. |
379 | 379 | $new_setting_fields[] = array( |
380 | 380 | 'type' => 'sectionend', |
@@ -406,52 +406,52 @@ discard block |
||
406 | 406 | |
407 | 407 | // Check if setting page has title section or not. |
408 | 408 | // If setting page does not have title section then add title section to it and fix section end array id. |
409 | - if ( 'title' !== $new_setting_fields[0]['type'] ) { |
|
409 | + if ('title' !== $new_setting_fields[0]['type']) { |
|
410 | 410 | array_unshift( |
411 | 411 | $new_setting_fields, |
412 | 412 | array( |
413 | - 'title' => ( isset( $settings['give_title'] ) ? $settings['give_title'] : '' ), |
|
413 | + 'title' => (isset($settings['give_title']) ? $settings['give_title'] : ''), |
|
414 | 414 | 'type' => 'title', |
415 | - 'desc' => ! empty( $setting_fields['desc'] ) ? $setting_fields['desc'] : '', |
|
416 | - 'id' => ( isset( $settings['id'] ) ? $settings['id'] : '' ), |
|
415 | + 'desc' => ! empty($setting_fields['desc']) ? $setting_fields['desc'] : '', |
|
416 | + 'id' => (isset($settings['id']) ? $settings['id'] : ''), |
|
417 | 417 | ) |
418 | 418 | ); |
419 | 419 | |
420 | 420 | // Update id in section end array if does not contain. |
421 | - if ( empty( $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] ) ) { |
|
422 | - $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] = ( isset( $settings['id'] ) ? $settings['id'] : '' ); |
|
421 | + if (empty($new_setting_fields[count($new_setting_fields) - 1]['id'])) { |
|
422 | + $new_setting_fields[count($new_setting_fields) - 1]['id'] = (isset($settings['id']) ? $settings['id'] : ''); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | 426 | // Return only section related settings. |
427 | - if ( $sections = $this->get_filtered_addon_sections() ) { |
|
428 | - $new_setting_fields = $this->get_section_settings( $new_setting_fields ); |
|
427 | + if ($sections = $this->get_filtered_addon_sections()) { |
|
428 | + $new_setting_fields = $this->get_section_settings($new_setting_fields); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // Third party plugin backward compatibility. |
432 | - $wp_filter_keys = array_keys( $wp_filter ); |
|
433 | - foreach ( $new_setting_fields as $index => $field ) { |
|
434 | - if ( ! isset( $field['type'] ) || in_array( $field['type'], array( 'title', 'sectionend' ) ) ) { |
|
432 | + $wp_filter_keys = array_keys($wp_filter); |
|
433 | + foreach ($new_setting_fields as $index => $field) { |
|
434 | + if ( ! isset($field['type']) || in_array($field['type'], array('title', 'sectionend'))) { |
|
435 | 435 | continue; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $cmb2_filter_name = "cmb2_render_{$field['type']}"; |
439 | 439 | |
440 | - if ( in_array( $cmb2_filter_name, $wp_filter_keys ) ) { |
|
440 | + if (in_array($cmb2_filter_name, $wp_filter_keys)) { |
|
441 | 441 | |
442 | - if ( 0 >= version_compare( 4.7, get_bloginfo( 'version' ) ) && ! empty( $wp_filter[ $cmb2_filter_name ]->callbacks ) ) { |
|
443 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ]->callbacks ); |
|
442 | + if (0 >= version_compare(4.7, get_bloginfo('version')) && ! empty($wp_filter[$cmb2_filter_name]->callbacks)) { |
|
443 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]->callbacks); |
|
444 | 444 | } else { |
445 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ] ); |
|
445 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]); |
|
446 | 446 | } |
447 | 447 | |
448 | - if ( ! empty( $cmb2_filter_arr ) ) { |
|
448 | + if ( ! empty($cmb2_filter_arr)) { |
|
449 | 449 | // Note: function can be called either globally or with class object, it depends on how developer invoke it. |
450 | - $new_setting_fields[ $index ]['func'] = current( $cmb2_filter_arr ); |
|
451 | - add_action( "give_admin_field_{$field['type']}", array( |
|
450 | + $new_setting_fields[$index]['func'] = current($cmb2_filter_arr); |
|
451 | + add_action("give_admin_field_{$field['type']}", array( |
|
452 | 452 | $this, |
453 | 453 | 'addon_setting_field', |
454 | - ), 10, 2 ); |
|
454 | + ), 10, 2); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -472,31 +472,31 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return array |
474 | 474 | */ |
475 | - function get_section_settings( $tab_settings ) { |
|
475 | + function get_section_settings($tab_settings) { |
|
476 | 476 | $current_section = give_get_current_setting_section(); |
477 | 477 | |
478 | 478 | // Note: If we are opening default tab for addon setting then it is possible that we will get empty string as current section |
479 | 479 | // because default section filter added after save hook fire, so we will always get problem to save first section [default] or if there are only on section |
480 | 480 | // This is hack to fix this. |
481 | - if ( empty( $current_section ) ) { |
|
482 | - $current_section = $this->set_default_setting_tab( $current_section ); |
|
481 | + if (empty($current_section)) { |
|
482 | + $current_section = $this->set_default_setting_tab($current_section); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | $section_start = false; |
486 | 486 | $section_end = false; |
487 | 487 | $section_only_setting_fields = array(); |
488 | 488 | |
489 | - foreach ( $tab_settings as $field ) { |
|
490 | - if ( 'title' == $field['type'] && $current_section == sanitize_title( $field['title'] ) ) { |
|
489 | + foreach ($tab_settings as $field) { |
|
490 | + if ('title' == $field['type'] && $current_section == sanitize_title($field['title'])) { |
|
491 | 491 | $section_start = true; |
492 | 492 | } |
493 | 493 | |
494 | - if ( ! $section_start || $section_end ) { |
|
494 | + if ( ! $section_start || $section_end) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | - if ( $section_start && ! $section_end ) { |
|
499 | - if ( 'sectionend' == $field['type'] ) { |
|
498 | + if ($section_start && ! $section_end) { |
|
499 | + if ('sectionend' == $field['type']) { |
|
500 | 500 | $section_end = true; |
501 | 501 | } |
502 | 502 | $section_only_setting_fields[] = $field; |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | // Remove title from setting, prevent it from render in setting tab. |
507 | 507 | $section_only_setting_fields[0]['title'] = ''; |
508 | 508 | |
509 | - return apply_filters( "give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings ); |
|
509 | + return apply_filters("give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | |
@@ -520,17 +520,17 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return void |
522 | 522 | */ |
523 | - function addon_setting_field( $field, $saved_value ) { |
|
523 | + function addon_setting_field($field, $saved_value) { |
|
524 | 524 | // Create object for cmb2 function callback backward compatibility. |
525 | 525 | // Note: Do not call any cmb2 function on these objects |
526 | - $field_obj = (object) array( 'args' => $field ); |
|
527 | - $field_type_obj = (object) array( 'field' => $field_obj ); |
|
526 | + $field_obj = (object) array('args' => $field); |
|
527 | + $field_type_obj = (object) array('field' => $field_obj); |
|
528 | 528 | |
529 | - switch ( $this->current_tab ) : |
|
529 | + switch ($this->current_tab) : |
|
530 | 530 | case 'licenses': |
531 | 531 | ?> |
532 | 532 | <div class="give-settings-wrap give-settings-wrap-<?php echo $this->current_tab; ?>"> |
533 | - <?php $field['func']['function']( $field_obj, $saved_value, '', '', $field_type_obj ); ?> |
|
533 | + <?php $field['func']['function']($field_obj, $saved_value, '', '', $field_type_obj); ?> |
|
534 | 534 | </div> |
535 | 535 | <?php break; |
536 | 536 | |
@@ -538,22 +538,22 @@ discard block |
||
538 | 538 | $colspan = 'colspan="2"'; |
539 | 539 | ?> |
540 | 540 | <tr valign="top"> |
541 | - <?php if ( ! empty( $field['name'] ) && ! in_array( $field['name'], array( ' ' ) ) ) : ?> |
|
541 | + <?php if ( ! empty($field['name']) && ! in_array($field['name'], array(' '))) : ?> |
|
542 | 542 | <th scope="row" class="titledesc"> |
543 | 543 | <label |
544 | - for="<?php echo esc_attr( $field['name'] ); ?>"><?php echo $field['title']; ?></label> |
|
544 | + for="<?php echo esc_attr($field['name']); ?>"><?php echo $field['title']; ?></label> |
|
545 | 545 | </th> |
546 | 546 | <?php $colspan = ''; ?> |
547 | 547 | <?php endif; ?> |
548 | 548 | <td class="give-forminp" <?php echo $colspan; ?>> |
549 | 549 | <?php |
550 | - if ( is_array( $field['func']['function'] ) ) { |
|
550 | + if (is_array($field['func']['function'])) { |
|
551 | 551 | $classname = $field['func']['function'][0]; |
552 | 552 | $function_name = $field['func']['function'][1]; |
553 | - $classname->$function_name( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
553 | + $classname->$function_name($field_obj, $saved_value, '', '', $field_type_obj); |
|
554 | 554 | } else { |
555 | 555 | $function_name = $field['func']['function']; |
556 | - $function_name( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
556 | + $function_name($field_obj, $saved_value, '', '', $field_type_obj); |
|
557 | 557 | } |
558 | 558 | ?> |
559 | 559 | </td> |
@@ -571,10 +571,10 @@ discard block |
||
571 | 571 | public function get_sections() { |
572 | 572 | $sections = array(); |
573 | 573 | |
574 | - if ( ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) && ! empty( $setting_fields['fields'] ) ) { |
|
575 | - foreach ( $setting_fields['fields'] as $field ) { |
|
576 | - if ( 'give_title' == $field['type'] ) { |
|
577 | - $sections[ sanitize_title( $field['name'] ) ] = $this->get_section_name( $field['name'] ); |
|
574 | + if (($setting_fields = $this->prev_settings->give_settings($this->current_tab)) && ! empty($setting_fields['fields'])) { |
|
575 | + foreach ($setting_fields['fields'] as $field) { |
|
576 | + if ('give_title' == $field['type']) { |
|
577 | + $sections[sanitize_title($field['name'])] = $this->get_section_name($field['name']); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | } |
@@ -594,16 +594,16 @@ discard block |
||
594 | 594 | |
595 | 595 | $new_setting_fields = array(); |
596 | 596 | |
597 | - if ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) { |
|
598 | - if ( isset( $setting_fields['fields'] ) ) { |
|
597 | + if ($setting_fields = $this->prev_settings->give_settings($this->current_tab)) { |
|
598 | + if (isset($setting_fields['fields'])) { |
|
599 | 599 | |
600 | 600 | $tab_data = array( |
601 | 601 | 'id' => $setting_fields['id'], |
602 | 602 | 'give_title' => $setting_fields['give_title'], |
603 | - 'desc' => ( isset( $setting_fields['desc'] ) ? $setting_fields['desc'] : '' ), |
|
603 | + 'desc' => (isset($setting_fields['desc']) ? $setting_fields['desc'] : ''), |
|
604 | 604 | ); |
605 | 605 | |
606 | - $new_setting_fields = $this->get_filtered_addon_settings( $setting_fields['fields'], $tab_data ); |
|
606 | + $new_setting_fields = $this->get_filtered_addon_settings($setting_fields['fields'], $tab_data); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
@@ -620,24 +620,24 @@ discard block |
||
620 | 620 | $sections = $this->get_sections(); |
621 | 621 | |
622 | 622 | // Show section settings only if setting section exist. |
623 | - if ( $this->current_section && ! in_array( $this->current_section, array_keys( $sections ) ) ) { |
|
624 | - echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
623 | + if ($this->current_section && ! in_array($this->current_section, array_keys($sections))) { |
|
624 | + echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; |
|
625 | 625 | $GLOBALS['give_hide_save_button'] = true; |
626 | 626 | |
627 | 627 | return; |
628 | 628 | } |
629 | 629 | |
630 | 630 | // Bailout. |
631 | - if ( empty( $sections ) ) { |
|
631 | + if (empty($sections)) { |
|
632 | 632 | return; |
633 | 633 | } |
634 | 634 | |
635 | 635 | echo '<ul class="subsubsub">'; |
636 | 636 | |
637 | - $array_keys = array_keys( $sections ); |
|
637 | + $array_keys = array_keys($sections); |
|
638 | 638 | |
639 | - foreach ( $sections as $id => $label ) { |
|
640 | - echo '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=' . $this->current_tab . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $this->current_section == $id ? 'current' : '' ) . '">' . strip_tags( $label ) . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>'; |
|
639 | + foreach ($sections as $id => $label) { |
|
640 | + echo '<li><a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings&tab='.$this->current_tab.'§ion='.sanitize_title($id)).'" class="'.($this->current_section == $id ? 'current' : '').'">'.strip_tags($label).'</a> '.(end($array_keys) == $id ? '' : '|').' </li>'; |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | echo '</ul><br class="clear" /><hr>'; |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | public function output() { |
653 | 653 | $settings = $this->get_settings(); |
654 | 654 | |
655 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
655 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | public function save() { |
665 | 665 | $settings = $this->get_settings(); |
666 | 666 | |
667 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
667 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | endif; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_General' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_General')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_General. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'general'; |
30 | - $this->label = __( 'General', 'give' ); |
|
30 | + $this->label = __('General', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'general-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'access-control': |
49 | 49 | $settings = array( |
50 | 50 | // Section 3: Access control. |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'id' => 'session_lifetime', |
57 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
58 | - 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
57 | + 'name' => __('Session Lifetime', 'give'), |
|
58 | + 'desc' => __('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => array( |
61 | - '86400' => __( '24 Hours', 'give' ), |
|
62 | - '172800' => __( '48 Hours', 'give' ), |
|
63 | - '259200' => __( '72 Hours', 'give' ), |
|
64 | - '604800' => __( '1 Week', 'give' ), |
|
61 | + '86400' => __('24 Hours', 'give'), |
|
62 | + '172800' => __('48 Hours', 'give'), |
|
63 | + '259200' => __('72 Hours', 'give'), |
|
64 | + '604800' => __('1 Week', 'give'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | array( |
68 | 68 | 'id' => 'limit_display_donations', |
69 | - 'name' => __( 'Limit Donations Displayed', 'give' ), |
|
70 | - 'desc' => __( 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give' ), |
|
69 | + 'name' => __('Limit Donations Displayed', 'give'), |
|
70 | + 'desc' => __('Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give'), |
|
71 | 71 | 'default' => '1', |
72 | 72 | 'type' => 'number', |
73 | 73 | 'css' => 'width:50px;', |
@@ -77,36 +77,36 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | array( |
80 | - 'name' => __( 'Email Access', 'give' ), |
|
81 | - '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' ), |
|
80 | + 'name' => __('Email Access', 'give'), |
|
81 | + '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'), |
|
82 | 82 | 'id' => 'email_access', |
83 | 83 | 'type' => 'radio_inline', |
84 | 84 | 'default' => 'disabled', |
85 | 85 | 'options' => array( |
86 | - 'enabled' => __( 'Enabled', 'give' ), |
|
87 | - 'disabled' => __( 'Disabled', 'give' ), |
|
86 | + 'enabled' => __('Enabled', 'give'), |
|
87 | + 'disabled' => __('Disabled', 'give'), |
|
88 | 88 | ), |
89 | 89 | ), |
90 | 90 | array( |
91 | 91 | 'id' => 'recaptcha_key', |
92 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
92 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
93 | 93 | /* translators: %s: https://www.google.com/recaptcha/ */ |
94 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ), |
|
94 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('http://docs.givewp.com/recaptcha')), |
|
95 | 95 | 'default' => '', |
96 | 96 | 'type' => 'text', |
97 | 97 | ), |
98 | 98 | array( |
99 | 99 | 'id' => 'recaptcha_secret', |
100 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
101 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ), |
|
100 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
101 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give'), |
|
102 | 102 | 'default' => '', |
103 | 103 | 'type' => 'text', |
104 | 104 | ), |
105 | 105 | array( |
106 | - 'name' => __( 'Access Control Docs Link', 'give' ), |
|
106 | + 'name' => __('Access Control Docs Link', 'give'), |
|
107 | 107 | 'id' => 'access_control_docs_link', |
108 | - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
109 | - 'title' => __( 'Access Control', 'give' ), |
|
108 | + 'url' => esc_url('http://docs.givewp.com/settings-access-control'), |
|
109 | + 'title' => __('Access Control', 'give'), |
|
110 | 110 | 'type' => 'give_docs_link', |
111 | 111 | ), |
112 | 112 | array( |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | 'id' => 'give_title_general_settings_2', |
125 | 125 | ), |
126 | 126 | array( |
127 | - 'name' => __( 'Currency Settings', 'give' ), |
|
127 | + 'name' => __('Currency Settings', 'give'), |
|
128 | 128 | 'desc' => '', |
129 | 129 | 'type' => 'give_title', |
130 | 130 | 'id' => 'give_title_general_settings_2', |
131 | 131 | ), |
132 | 132 | array( |
133 | - 'name' => __( 'Currency', 'give' ), |
|
134 | - 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
133 | + 'name' => __('Currency', 'give'), |
|
134 | + 'desc' => __('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
135 | 135 | 'id' => 'currency', |
136 | 136 | 'class' => 'give-select-chosen', |
137 | 137 | 'type' => 'select', |
@@ -139,47 +139,47 @@ discard block |
||
139 | 139 | 'default' => 'USD', |
140 | 140 | ), |
141 | 141 | array( |
142 | - 'name' => __( 'Currency Position', 'give' ), |
|
143 | - 'desc' => __( 'The position of the currency symbol.', 'give' ), |
|
142 | + 'name' => __('Currency Position', 'give'), |
|
143 | + 'desc' => __('The position of the currency symbol.', 'give'), |
|
144 | 144 | 'id' => 'currency_position', |
145 | 145 | 'type' => 'select', |
146 | 146 | 'options' => array( |
147 | 147 | /* translators: %s: currency symbol */ |
148 | - 'before' => sprintf( __( 'Before - %s‎10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
148 | + 'before' => sprintf(__('Before - %s‎10', 'give'), give_currency_symbol(give_get_currency())), |
|
149 | 149 | /* translators: %s: currency symbol */ |
150 | - 'after' => sprintf( __( 'After - 10%s‏', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
150 | + 'after' => sprintf(__('After - 10%s‏', 'give'), give_currency_symbol(give_get_currency())), |
|
151 | 151 | ), |
152 | 152 | 'default' => 'before', |
153 | 153 | ), |
154 | 154 | array( |
155 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
156 | - 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ), |
|
155 | + 'name' => __('Thousands Separator', 'give'), |
|
156 | + 'desc' => __('The symbol (typically , or .) to separate thousands.', 'give'), |
|
157 | 157 | 'id' => 'thousands_separator', |
158 | 158 | 'type' => 'text', |
159 | 159 | 'default' => ',', |
160 | 160 | 'css' => 'width:12em;', |
161 | 161 | ), |
162 | 162 | array( |
163 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
164 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
163 | + 'name' => __('Decimal Separator', 'give'), |
|
164 | + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
165 | 165 | 'id' => 'decimal_separator', |
166 | 166 | 'type' => 'text', |
167 | 167 | 'default' => '.', |
168 | 168 | 'css' => 'width:12em;', |
169 | 169 | ), |
170 | 170 | array( |
171 | - 'name' => __( 'Number of Decimals', 'give' ), |
|
172 | - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ), |
|
171 | + 'name' => __('Number of Decimals', 'give'), |
|
172 | + 'desc' => __('The number of decimal points displayed in amounts.', 'give'), |
|
173 | 173 | 'id' => 'number_decimals', |
174 | 174 | 'type' => 'text', |
175 | 175 | 'default' => 2, |
176 | 176 | 'css' => 'width:12em;', |
177 | 177 | ), |
178 | 178 | array( |
179 | - 'name' => __( 'Currency Options Docs Link', 'give' ), |
|
179 | + 'name' => __('Currency Options Docs Link', 'give'), |
|
180 | 180 | 'id' => 'currency_settings_docs_link', |
181 | - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
182 | - 'title' => __( 'Currency Settings', 'give' ), |
|
181 | + 'url' => esc_url('http://docs.givewp.com/settings-currency'), |
|
182 | + 'title' => __('Currency Settings', 'give'), |
|
183 | 183 | 'type' => 'give_docs_link', |
184 | 184 | ), |
185 | 185 | array( |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $country = give_get_country(); |
195 | 195 | |
196 | 196 | // get the list of the states of which default country is selected. |
197 | - $states = give_get_states( $country ); |
|
197 | + $states = give_get_states($country); |
|
198 | 198 | |
199 | 199 | // Get the country list that does not have any states init. |
200 | 200 | $no_states_country = give_no_states_country_list(); |
@@ -206,46 +206,46 @@ discard block |
||
206 | 206 | 'id' => 'give_title_general_settings_1', |
207 | 207 | ), |
208 | 208 | array( |
209 | - 'name' => __( 'General Settings', 'give' ), |
|
209 | + 'name' => __('General Settings', 'give'), |
|
210 | 210 | 'desc' => '', |
211 | 211 | 'type' => 'give_title', |
212 | 212 | 'id' => 'give_title_general_settings_1', |
213 | 213 | ), |
214 | 214 | array( |
215 | - 'name' => __( 'Success Page', 'give' ), |
|
215 | + 'name' => __('Success Page', 'give'), |
|
216 | 216 | /* translators: %s: [give_receipt] */ |
217 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
217 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
218 | 218 | 'id' => 'success_page', |
219 | 219 | 'type' => 'select', |
220 | - 'options' => give_cmb2_get_post_options( array( |
|
220 | + 'options' => give_cmb2_get_post_options(array( |
|
221 | 221 | 'post_type' => 'page', |
222 | 222 | 'numberposts' => 999, |
223 | - ) ), |
|
223 | + )), |
|
224 | 224 | ), |
225 | 225 | array( |
226 | - 'name' => __( 'Failed Donation Page', 'give' ), |
|
227 | - 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
226 | + 'name' => __('Failed Donation Page', 'give'), |
|
227 | + 'desc' => __('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
228 | 228 | 'id' => 'failure_page', |
229 | 229 | 'type' => 'select', |
230 | - 'options' => give_cmb2_get_post_options( array( |
|
230 | + 'options' => give_cmb2_get_post_options(array( |
|
231 | 231 | 'post_type' => 'page', |
232 | 232 | 'numberposts' => 999, |
233 | - ) ), |
|
233 | + )), |
|
234 | 234 | ), |
235 | 235 | array( |
236 | - 'name' => __( 'Donation History Page', 'give' ), |
|
236 | + 'name' => __('Donation History Page', 'give'), |
|
237 | 237 | /* translators: %s: [donation_history] */ |
238 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
238 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
239 | 239 | 'id' => 'history_page', |
240 | 240 | 'type' => 'select', |
241 | - 'options' => give_cmb2_get_post_options( array( |
|
241 | + 'options' => give_cmb2_get_post_options(array( |
|
242 | 242 | 'post_type' => 'page', |
243 | 243 | 'numberposts' => 999, |
244 | - ) ), |
|
244 | + )), |
|
245 | 245 | ), |
246 | 246 | array( |
247 | - 'name' => __( 'Base Country', 'give' ), |
|
248 | - 'desc' => __( 'The country your site operates from.', 'give' ), |
|
247 | + 'name' => __('Base Country', 'give'), |
|
248 | + 'desc' => __('The country your site operates from.', 'give'), |
|
249 | 249 | 'id' => 'base_country', |
250 | 250 | 'type' => 'select', |
251 | 251 | 'options' => give_get_country_list(), |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | * @since 1.8.14 |
257 | 257 | */ |
258 | 258 | array( |
259 | - 'wrapper_class' => ( array_key_exists( $country, $no_states_country ) ? 'give-hidden' : '' ), |
|
260 | - 'name' => __( 'Base State/Province', 'give' ), |
|
261 | - 'desc' => __( 'The state/province your site operates from.', 'give' ), |
|
259 | + 'wrapper_class' => (array_key_exists($country, $no_states_country) ? 'give-hidden' : ''), |
|
260 | + 'name' => __('Base State/Province', 'give'), |
|
261 | + 'desc' => __('The state/province your site operates from.', 'give'), |
|
262 | 262 | 'id' => 'base_state', |
263 | - 'type' => ( empty( $states ) ? 'text' : 'select' ), |
|
263 | + 'type' => (empty($states) ? 'text' : 'select'), |
|
264 | 264 | 'options' => $states, |
265 | 265 | ), |
266 | 266 | array( |
267 | - 'name' => __( 'General Options Docs Link', 'give' ), |
|
267 | + 'name' => __('General Options Docs Link', 'give'), |
|
268 | 268 | 'id' => 'general_options_docs_link', |
269 | - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
270 | - 'title' => __( 'General Options', 'give' ), |
|
269 | + 'url' => esc_url('http://docs.givewp.com/settings-general'), |
|
270 | + 'title' => __('General Options', 'give'), |
|
271 | 271 | 'type' => 'give_docs_link', |
272 | 272 | ), |
273 | 273 | array( |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Filter the general settings. |
283 | 283 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
284 | 284 | */ |
285 | - $settings = apply_filters( 'give_settings_general', $settings ); |
|
285 | + $settings = apply_filters('give_settings_general', $settings); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Filter the settings. |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @param array $settings |
293 | 293 | */ |
294 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
294 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
295 | 295 | |
296 | 296 | // Output. |
297 | 297 | return $settings; |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function get_sections() { |
307 | 307 | $sections = array( |
308 | - 'general-settings' => __( 'General', 'give' ), |
|
309 | - 'currency-settings' => __( 'Currency', 'give' ), |
|
310 | - 'access-control' => __( 'Access Control', 'give' ), |
|
308 | + 'general-settings' => __('General', 'give'), |
|
309 | + 'currency-settings' => __('Currency', 'give'), |
|
310 | + 'access-control' => __('Access Control', 'give'), |
|
311 | 311 | ); |
312 | 312 | |
313 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
313 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 |
@@ -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 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
69 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Check spam through Akismet. |
@@ -80,45 +80,45 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool|mixed |
82 | 82 | */ |
83 | -function give_akismet( $spam ) { |
|
83 | +function give_akismet($spam) { |
|
84 | 84 | |
85 | 85 | // Bail out, If spam. |
86 | - if ( $spam ) { |
|
86 | + if ($spam) { |
|
87 | 87 | return $spam; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Bail out, if Akismet key not exist. |
91 | - if ( ! give_check_akismet_key() ) { |
|
91 | + if ( ! give_check_akismet_key()) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Build args array. |
96 | 96 | $args = array(); |
97 | 97 | |
98 | - $args['comment_author'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
99 | - $args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
100 | - $args['blog'] = get_option( 'home' ); |
|
98 | + $args['comment_author'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
99 | + $args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
100 | + $args['blog'] = get_option('home'); |
|
101 | 101 | $args['blog_lang'] = get_locale(); |
102 | - $args['blog_charset'] = get_option( 'blog_charset' ); |
|
102 | + $args['blog_charset'] = get_option('blog_charset'); |
|
103 | 103 | $args['user_ip'] = $_SERVER['REMOTE_ADDR']; |
104 | 104 | $args['user_agent'] = $_SERVER['HTTP_USER_AGENT']; |
105 | 105 | $args['referrer'] = $_SERVER['HTTP_REFERER']; |
106 | 106 | $args['comment_type'] = 'contact-form'; |
107 | 107 | |
108 | - $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); |
|
108 | + $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'); |
|
109 | 109 | |
110 | - foreach ( $_SERVER as $key => $value ) { |
|
111 | - if ( ! in_array( $key, (array) $ignore ) ) { |
|
110 | + foreach ($_SERVER as $key => $value) { |
|
111 | + if ( ! in_array($key, (array) $ignore)) { |
|
112 | 112 | $args["$key"] = $value; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // It will return Akismet spam detect API response. |
117 | - return give_akismet_spam_check( $args ); |
|
117 | + return give_akismet_spam_check($args); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | -add_filter( 'give_spam', 'give_akismet' ); |
|
121 | +add_filter('give_spam', 'give_akismet'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Check Akismet API Key. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * @return bool |
129 | 129 | */ |
130 | 130 | function give_check_akismet_key() { |
131 | - if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+ |
|
131 | + if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+ |
|
132 | 132 | return (bool) Akismet::get_api_key(); |
133 | 133 | } |
134 | 134 | |
135 | - if ( function_exists( 'akismet_get_key' ) ) { |
|
135 | + if (function_exists('akismet_get_key')) { |
|
136 | 136 | return (bool) akismet_get_key(); |
137 | 137 | } |
138 | 138 | |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool|mixed |
150 | 150 | */ |
151 | -function give_akismet_spam_check( $args ) { |
|
151 | +function give_akismet_spam_check($args) { |
|
152 | 152 | global $akismet_api_host, $akismet_api_port; |
153 | 153 | |
154 | 154 | $spam = false; |
155 | - $query_string = http_build_query( $args ); |
|
155 | + $query_string = http_build_query($args); |
|
156 | 156 | |
157 | - if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+ |
|
158 | - $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
157 | + if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+ |
|
158 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
159 | 159 | } else { |
160 | - $response = akismet_http_post( $query_string, $akismet_api_host, |
|
161 | - '/1.1/comment-check', $akismet_api_port ); |
|
160 | + $response = akismet_http_post($query_string, $akismet_api_host, |
|
161 | + '/1.1/comment-check', $akismet_api_port); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // It's spam if response status is true. |
165 | - if ( 'true' === $response[1] ) { |
|
165 | + if ('true' === $response[1]) { |
|
166 | 166 | $spam = true; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Allow developer to modified Akismet spam detection response. |
170 | - return apply_filters( 'give_akismet_spam_check', $spam, $args ); |
|
170 | + return apply_filters('give_akismet_spam_check', $spam, $args); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return array |
182 | 182 | */ |
183 | -function give_bc_v1817_iranian_currency_code( $currencies ) { |
|
184 | - if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) { |
|
183 | +function give_bc_v1817_iranian_currency_code($currencies) { |
|
184 | + if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) { |
|
185 | 185 | $currencies['RIAL'] = $currencies['IRR']; |
186 | 186 | } |
187 | 187 | |
188 | 188 | return $currencies; |
189 | 189 | } |
190 | 190 | |
191 | -add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 ); |
|
191 | +add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0); |
|
192 | 192 | |
193 | 193 | |
194 | 194 | /** |
@@ -202,22 +202,20 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | -function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) { |
|
206 | - if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) { |
|
205 | +function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) { |
|
206 | + if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) { |
|
207 | 207 | return $formatted_amount; |
208 | 208 | } |
209 | 209 | |
210 | 210 | $formatted_amount = ( |
211 | 211 | 'before' === (string) $currency_args['position'] ? |
212 | - '‫' . $price . $currency_args['symbol'] . '‬' : |
|
213 | - '‪' . $price . $currency_args['symbol'] . '‬' |
|
212 | + '‫'.$price.$currency_args['symbol'].'‬' : '‪'.$price.$currency_args['symbol'].'‬' |
|
214 | 213 | ); |
215 | 214 | |
216 | 215 | $formatted_amount = $currency_args['decode_currency'] ? |
217 | - html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) : |
|
218 | - $formatted_amount; |
|
216 | + html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount; |
|
219 | 217 | |
220 | 218 | return $formatted_amount; |
221 | 219 | } |
222 | 220 | |
223 | -add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 ); |
|
224 | 221 | \ No newline at end of file |
222 | +add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3); |
|
225 | 223 | \ 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 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
87 | 87 | */ |
88 | - public function __construct( $args = array() ) { |
|
88 | + public function __construct($args = array()) { |
|
89 | 89 | $defaults = array( |
90 | 90 | 'number' => 20, |
91 | 91 | 'offset' => 0, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // 'form' => array(), |
104 | 104 | ); |
105 | 105 | |
106 | - $this->args = wp_parse_args( $args, $defaults ); |
|
106 | + $this->args = wp_parse_args($args, $defaults); |
|
107 | 107 | |
108 | 108 | $this->table_name = Give()->donors->table_name; |
109 | 109 | $this->meta_table_name = Give()->donor_meta->table_name; |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param Give_Donors_Query $this Donors query object. |
148 | 148 | */ |
149 | - do_action( 'give_pre_get_donors', $this ); |
|
149 | + do_action('give_pre_get_donors', $this); |
|
150 | 150 | |
151 | - if ( empty( $this->args['count'] ) ) { |
|
152 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
151 | + if (empty($this->args['count'])) { |
|
152 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
153 | 153 | } else { |
154 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
154 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param Give_Donors_Query $this Donors query object. |
163 | 163 | */ |
164 | - do_action( 'give_post_get_donors', $this ); |
|
164 | + do_action('give_post_get_donors', $this); |
|
165 | 165 | |
166 | 166 | return $this->donors; |
167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function get_sql() { |
179 | 179 | global $wpdb; |
180 | 180 | |
181 | - if ( $this->args['number'] < 1 ) { |
|
181 | + if ($this->args['number'] < 1) { |
|
182 | 182 | $this->args['number'] = 999999999999; |
183 | 183 | } |
184 | 184 | |
@@ -186,22 +186,22 @@ discard block |
||
186 | 186 | |
187 | 187 | |
188 | 188 | // Set offset. |
189 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
190 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
189 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
190 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // Set fields. |
194 | 194 | $fields = "{$this->table_name}.*"; |
195 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
196 | - if ( is_string( $this->args['fields'] ) ) { |
|
195 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
196 | + if (is_string($this->args['fields'])) { |
|
197 | 197 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
198 | - } else if ( is_array( $this->args['fields'] ) ) { |
|
199 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
198 | + } else if (is_array($this->args['fields'])) { |
|
199 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Set count. |
204 | - if ( ! empty( $this->args['count'] ) ) { |
|
204 | + if ( ! empty($this->args['count'])) { |
|
205 | 205 | $fields = "COUNT({$this->table_name}.id)"; |
206 | 206 | } |
207 | 207 | |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | |
210 | 210 | $sql = $wpdb->prepare( |
211 | 211 | "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", |
212 | - absint( $this->args['offset'] ), |
|
213 | - absint( $this->args['number'] ) |
|
212 | + absint($this->args['offset']), |
|
213 | + absint($this->args['number']) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
217 | 217 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
218 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql ); |
|
218 | + $sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql); |
|
219 | 219 | |
220 | 220 | return $sql; |
221 | 221 | } |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | $where = ''; |
234 | 234 | |
235 | 235 | // Get sql query for meta. |
236 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
237 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
236 | + if ( ! empty($this->args['meta_query'])) { |
|
237 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
238 | 238 | $meta_query = $meta_query_object->get_sql( |
239 | 239 | $this->meta_type, |
240 | 240 | $this->table_name, |
241 | 241 | 'id' |
242 | 242 | ); |
243 | 243 | |
244 | - $where = implode( '', $meta_query ); |
|
244 | + $where = implode('', $meta_query); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | $where .= 'WHERE 1=1 '; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $where .= $this->get_where_user(); |
252 | 252 | $where .= $this->get_where_date(); |
253 | 253 | |
254 | - return trim( $where ); |
|
254 | + return trim($where); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | |
269 | 269 | $where = ''; |
270 | 270 | |
271 | - if ( ! empty( $this->args['email'] ) ) { |
|
271 | + if ( ! empty($this->args['email'])) { |
|
272 | 272 | |
273 | - if ( is_array( $this->args['email'] ) ) { |
|
273 | + if (is_array($this->args['email'])) { |
|
274 | 274 | |
275 | - $emails_count = count( $this->args['email'] ); |
|
276 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
277 | - $emails = implode( ', ', $emails_placeholder ); |
|
275 | + $emails_count = count($this->args['email']); |
|
276 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
277 | + $emails = implode(', ', $emails_placeholder); |
|
278 | 278 | |
279 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
279 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
280 | 280 | } else { |
281 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
281 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -298,11 +298,11 @@ discard block |
||
298 | 298 | $where = ''; |
299 | 299 | |
300 | 300 | // Specific donors. |
301 | - if ( ! empty( $this->args['donor'] ) ) { |
|
302 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
303 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
301 | + if ( ! empty($this->args['donor'])) { |
|
302 | + if ( ! is_array($this->args['donor'])) { |
|
303 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
304 | 304 | } |
305 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
305 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
306 | 306 | |
307 | 307 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
308 | 308 | } |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | $where = ''; |
324 | 324 | |
325 | 325 | // Donors created for a specific date or in a date range |
326 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
326 | + if ( ! empty($this->args['date_query'])) { |
|
327 | 327 | $date_query_object = new WP_Date_Query( |
328 | - is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), |
|
328 | + is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), |
|
329 | 329 | "{$this->table_name}.date_created" |
330 | 330 | ); |
331 | 331 | |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | $where = ''; |
361 | 361 | |
362 | 362 | // Donors created for a specific date or in a date range |
363 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
364 | - $search_parts = explode( ':', $this->args['s'] ); |
|
363 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
364 | + $search_parts = explode(':', $this->args['s']); |
|
365 | 365 | |
366 | - if ( ! empty( $search_parts[0] ) ) { |
|
367 | - switch ( $search_parts[0] ) { |
|
366 | + if ( ! empty($search_parts[0])) { |
|
367 | + switch ($search_parts[0]) { |
|
368 | 368 | case 'name': |
369 | 369 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
370 | 370 | break; |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | $where = ''; |
393 | 393 | |
394 | 394 | // Donors create for specific wp user. |
395 | - if ( ! empty( $this->args['user'] ) ) { |
|
396 | - if ( ! is_array( $this->args['user'] ) ) { |
|
397 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
395 | + if ( ! empty($this->args['user'])) { |
|
396 | + if ( ! is_array($this->args['user'])) { |
|
397 | + $this->args['user'] = explode(',', $this->args['user']); |
|
398 | 398 | } |
399 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
399 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
400 | 400 | |
401 | 401 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
402 | 402 | } |
@@ -415,14 +415,13 @@ discard block |
||
415 | 415 | private function get_order_query() { |
416 | 416 | $table_columns = Give()->donors->get_columns(); |
417 | 417 | |
418 | - $this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ? |
|
419 | - 'id' : |
|
420 | - $this->args['orderby']; |
|
418 | + $this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ? |
|
419 | + 'id' : $this->args['orderby']; |
|
421 | 420 | |
422 | - $this->args['orderby'] = esc_sql( $this->args['orderby'] ); |
|
423 | - $this->args['order'] = esc_sql( $this->args['order'] ); |
|
421 | + $this->args['orderby'] = esc_sql($this->args['orderby']); |
|
422 | + $this->args['order'] = esc_sql($this->args['order']); |
|
424 | 423 | |
425 | - switch ( $table_columns[ $this->args['orderby'] ] ) { |
|
424 | + switch ($table_columns[$this->args['orderby']]) { |
|
426 | 425 | case '%d': |
427 | 426 | case '%f': |
428 | 427 | $query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0"; |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.8.13 |
21 | 21 | */ |
22 | 22 | function give_import_donation_report() { |
23 | - return get_option( 'give_import_donation_report', array() ); |
|
23 | + return get_option('give_import_donation_report', array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8.13 |
31 | 31 | */ |
32 | -function give_import_donation_report_update( $value = array() ) { |
|
33 | - update_option( 'give_import_donation_report', $value ); |
|
32 | +function give_import_donation_report_update($value = array()) { |
|
33 | + update_option('give_import_donation_report', $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @since 1.8.13 |
41 | 41 | */ |
42 | 42 | function give_import_donation_report_reset() { |
43 | - update_option( 'give_import_donation_report', array() ); |
|
43 | + update_option('give_import_donation_report', array()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
54 | 54 | */ |
55 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
55 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
56 | 56 | $new_form = false; |
57 | 57 | |
58 | 58 | // Get the import report |
@@ -61,58 +61,58 @@ discard block |
||
61 | 61 | $form = false; |
62 | 62 | $meta = array(); |
63 | 63 | |
64 | - if ( ! empty( $data['form_id'] ) ) { |
|
65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
64 | + if ( ! empty($data['form_id'])) { |
|
65 | + $form = new Give_Donate_Form($data['form_id']); |
|
66 | 66 | // Add support to older php version. |
67 | 67 | $form_id = $form->get_ID(); |
68 | - if ( empty( $form_id ) ) { |
|
69 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
68 | + if (empty($form_id)) { |
|
69 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
70 | 70 | $form = false; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
75 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
74 | + if (false === $form && ! empty($data['form_title'])) { |
|
75 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
76 | 76 | |
77 | - if ( ! empty( $form->ID ) ) { |
|
77 | + if ( ! empty($form->ID)) { |
|
78 | 78 | |
79 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
79 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
80 | 80 | |
81 | - $form = new Give_Donate_Form( $form->ID ); |
|
81 | + $form = new Give_Donate_Form($form->ID); |
|
82 | 82 | } else { |
83 | 83 | $form = new Give_Donate_Form(); |
84 | 84 | $args = array( |
85 | 85 | 'post_title' => $data['form_title'], |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | ); |
88 | - $form = $form->create( $args ); |
|
89 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
88 | + $form = $form->create($args); |
|
89 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
90 | 90 | $new_form = true; |
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
95 | - $form = new Give_Donate_Form( $form->ID ); |
|
94 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
95 | + $form = new Give_Donate_Form($form->ID); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
99 | - if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) { |
|
98 | + if ( ! empty($form) && $form->get_ID()) { |
|
99 | + if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) { |
|
100 | 100 | $prices = (array) $form->get_prices(); |
101 | 101 | $price_text = array(); |
102 | - foreach ( $prices as $key => $price ) { |
|
103 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
104 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' ); |
|
102 | + foreach ($prices as $key => $price) { |
|
103 | + if (isset($price['_give_id']['level_id'])) { |
|
104 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : ''); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! in_array( $data['form_level'], $price_text ) ) { |
|
108 | + if ( ! in_array($data['form_level'], $price_text)) { |
|
109 | 109 | |
110 | 110 | // For generating unquiet level id. |
111 | 111 | $count = 1; |
112 | - $new_level = count( $prices ) + $count; |
|
113 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
114 | - $count ++; |
|
115 | - $new_level = count( $prices ) + $count; |
|
112 | + $new_level = count($prices) + $count; |
|
113 | + while (array_key_exists($new_level, $price_text)) { |
|
114 | + $count++; |
|
115 | + $new_level = count($prices) + $count; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $multi_level_donations = array( |
@@ -120,57 +120,57 @@ discard block |
||
120 | 120 | '_give_id' => array( |
121 | 121 | 'level_id' => $new_level, |
122 | 122 | ), |
123 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
123 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
124 | 124 | '_give_text' => $data['form_level'], |
125 | 125 | ), |
126 | 126 | ); |
127 | 127 | |
128 | - $price_text[ $new_level ] = $data['form_level']; |
|
128 | + $price_text[$new_level] = $data['form_level']; |
|
129 | 129 | |
130 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
131 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
130 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
131 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
132 | 132 | |
133 | 133 | // Sort $prices by amount in ascending order. |
134 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
134 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
135 | 135 | } else { |
136 | 136 | $prices = $multi_level_donations; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Unset _give_default key from $prices. |
140 | - foreach ( $prices as $key => $price ) { |
|
141 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
142 | - unset( $prices[ $key ]['_give_default'] ); |
|
140 | + foreach ($prices as $key => $price) { |
|
141 | + if (isset($prices[$key]['_give_default'])) { |
|
142 | + unset($prices[$key]['_give_default']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Set the first $price of the $prices as defalut. |
147 | 147 | $prices[0]['_give_default'] = 'default'; |
148 | 148 | } |
149 | - $form->price_id = array_search( $data['form_level'], $price_text ); |
|
149 | + $form->price_id = array_search($data['form_level'], $price_text); |
|
150 | 150 | |
151 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
152 | - $min_amount = min( $donation_levels_amounts ); |
|
153 | - $max_amount = max( $donation_levels_amounts ); |
|
151 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
152 | + $min_amount = min($donation_levels_amounts); |
|
153 | + $max_amount = max($donation_levels_amounts); |
|
154 | 154 | |
155 | 155 | $meta = array( |
156 | 156 | '_give_levels_minimum_amount' => $min_amount, |
157 | 157 | '_give_levels_maximum_amount' => $max_amount, |
158 | 158 | '_give_price_option' => 'multi', |
159 | - '_give_donation_levels' => array_values( $prices ), |
|
159 | + '_give_donation_levels' => array_values($prices), |
|
160 | 160 | ); |
161 | 161 | } else { |
162 | 162 | $form->price_id = 'custom'; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $defaults = array( |
166 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
166 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
167 | 167 | '_give_price_option' => 'set', |
168 | 168 | ); |
169 | 169 | |
170 | 170 | // If new form is created. |
171 | - if ( ! empty( $new_form ) ) { |
|
171 | + if ( ! empty($new_form)) { |
|
172 | 172 | $new_form = array( |
173 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
173 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
174 | 174 | '_give_logged_in_only' => 'enabled', |
175 | 175 | '_give_custom_amount' => 'enabled', |
176 | 176 | '_give_payment_import' => true, |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | '_give_default_gateway' => 'global', |
182 | 182 | '_give_show_register_form' => 'both', |
183 | 183 | ); |
184 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
184 | + $defaults = wp_parse_args($defaults, $new_form); |
|
185 | 185 | } |
186 | 186 | |
187 | - $meta = wp_parse_args( $meta, $defaults ); |
|
187 | + $meta = wp_parse_args($meta, $defaults); |
|
188 | 188 | |
189 | - foreach ( $meta as $key => $value ) { |
|
190 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
189 | + foreach ($meta as $key => $value) { |
|
190 | + give_update_meta($form->get_ID(), $key, $value); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | // update the report |
195 | - give_import_donation_report_update( $report ); |
|
195 | + give_import_donation_report_update($report); |
|
196 | 196 | |
197 | 197 | return $form; |
198 | 198 | } |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return bool|false|WP_User |
208 | 208 | */ |
209 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
209 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
210 | 210 | $report = give_import_donation_report(); |
211 | 211 | $donor_data = false; |
212 | 212 | $customer_id = false; |
213 | 213 | |
214 | 214 | // check if donor id is not empty |
215 | - if ( ! empty( $data['donor_id'] ) ) { |
|
216 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
217 | - if ( ! empty( $donor_data->id ) ) { |
|
218 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
215 | + if ( ! empty($data['donor_id'])) { |
|
216 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
217 | + if ( ! empty($donor_data->id)) { |
|
218 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
222 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
223 | 223 | $user_id = (int) $data['user_id']; |
224 | - $donor_data = new Give_Donor( $user_id, true ); |
|
224 | + $donor_data = new Give_Donor($user_id, true); |
|
225 | 225 | |
226 | 226 | |
227 | - if ( empty( $donor_data->id ) ) { |
|
228 | - $donor_data = get_user_by( 'id', $user_id ); |
|
229 | - if ( ! empty( $donor_data->ID ) ) { |
|
230 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
231 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
232 | - $name = $first_name . ' ' . $last_name; |
|
227 | + if (empty($donor_data->id)) { |
|
228 | + $donor_data = get_user_by('id', $user_id); |
|
229 | + if ( ! empty($donor_data->ID)) { |
|
230 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
231 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
232 | + $name = $first_name.' '.$last_name; |
|
233 | 233 | $user_email = $donor_data->user_email; |
234 | 234 | $donor_args = array( |
235 | 235 | 'name' => $name, |
@@ -238,44 +238,44 @@ discard block |
||
238 | 238 | ); |
239 | 239 | |
240 | 240 | $donor_data = new Give_Donor(); |
241 | - $donor_data->create( $donor_args ); |
|
241 | + $donor_data->create($donor_args); |
|
242 | 242 | |
243 | 243 | // Adding notes that donor is being imported from CSV. |
244 | 244 | $current_user = wp_get_current_user(); |
245 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
245 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
246 | 246 | |
247 | 247 | // Add is used to ensure duplicate emails are not added |
248 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
249 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
248 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
249 | + $donor_data->add_meta('additional_email', $data['email']); |
|
250 | 250 | } |
251 | 251 | |
252 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
252 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
253 | 253 | } else { |
254 | 254 | } |
255 | 255 | } else { |
256 | 256 | // Add is used to ensure duplicate emails are not added |
257 | - if ( $donor_data->email != $data['email'] ) { |
|
258 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
257 | + if ($donor_data->email != $data['email']) { |
|
258 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
259 | 259 | } |
260 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
260 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
264 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
265 | 265 | |
266 | - $donor_data = new Give_Donor( $data['email'] ); |
|
267 | - if ( empty( $donor_data->id ) ) { |
|
268 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
266 | + $donor_data = new Give_Donor($data['email']); |
|
267 | + if (empty($donor_data->id)) { |
|
268 | + $donor_data = get_user_by('email', $data['email']); |
|
269 | 269 | |
270 | - if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
271 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
270 | + if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
271 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
272 | 272 | $donor_args = array( |
273 | 273 | 'user_login' => $data['email'], |
274 | 274 | 'user_email' => $data['email'], |
275 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
275 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
276 | 276 | 'user_first' => $data['first_name'], |
277 | 277 | 'user_last' => $data['last_name'], |
278 | - 'user_pass' => wp_generate_password( 8, true ), |
|
278 | + 'user_pass' => wp_generate_password(8, true), |
|
279 | 279 | 'role' => $give_role, |
280 | 280 | ); |
281 | 281 | |
@@ -284,56 +284,56 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 1.8.13 |
286 | 286 | */ |
287 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
287 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
288 | 288 | |
289 | 289 | // This action was added to remove the login when using the give register function. |
290 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
291 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
292 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
290 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
291 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
292 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
293 | 293 | |
294 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
295 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
294 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
295 | + $donor_data = new Give_Donor($customer_id, true); |
|
296 | 296 | } else { |
297 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
297 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
298 | 298 | } |
299 | 299 | |
300 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
301 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
300 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
301 | + $donor_data = new Give_Donor($customer_id, true); |
|
302 | 302 | |
303 | - if ( empty( $donor_data->id ) ) { |
|
303 | + if (empty($donor_data->id)) { |
|
304 | 304 | |
305 | - if ( ! empty( $data['form_id'] ) ) { |
|
306 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
305 | + if ( ! empty($data['form_id'])) { |
|
306 | + $form = new Give_Donate_Form($data['form_id']); |
|
307 | 307 | } |
308 | 308 | |
309 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
309 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
310 | 310 | $donor_args = array( |
311 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
311 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
312 | 312 | 'email' => $data['email'], |
313 | 313 | ); |
314 | 314 | |
315 | - if ( ! empty( $customer_id ) ) { |
|
315 | + if ( ! empty($customer_id)) { |
|
316 | 316 | $donor_args['user_id'] = $customer_id; |
317 | 317 | } |
318 | 318 | |
319 | - $donor_data->create( $donor_args ); |
|
319 | + $donor_data->create($donor_args); |
|
320 | 320 | |
321 | 321 | // Adding notes that donor is being imported from CSV. |
322 | 322 | $current_user = wp_get_current_user(); |
323 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
323 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
324 | 324 | |
325 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
325 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
326 | 326 | } else { |
327 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
327 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } else { |
331 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
331 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | 335 | // update the report |
336 | - give_import_donation_report_update( $report ); |
|
336 | + give_import_donation_report_update($report); |
|
337 | 337 | |
338 | 338 | return $donor_data; |
339 | 339 | } |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return array |
353 | 353 | */ |
354 | - return (array) apply_filters( 'give_import_default_options', array( |
|
355 | - '' => __( 'Do not import', 'give' ), |
|
356 | - ) ); |
|
354 | + return (array) apply_filters('give_import_default_options', array( |
|
355 | + '' => __('Do not import', 'give'), |
|
356 | + )); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -369,33 +369,33 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return array |
371 | 371 | */ |
372 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
373 | - 'id' => __( 'Donation ID', 'give' ), |
|
374 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
375 | - 'post_date' => __( 'Donation Date', 'give' ), |
|
376 | - 'first_name' => __( 'Donor First Name', 'give' ), |
|
377 | - 'last_name' => __( 'Donor Last Name', 'give' ), |
|
378 | - 'line1' => __( 'Address 1', 'give' ), |
|
379 | - 'line2' => __( 'Address 2', 'give' ), |
|
380 | - 'city' => __( 'City', 'give' ), |
|
381 | - 'state' => __( 'State', 'give' ), |
|
372 | + return (array) apply_filters('give_import_donations_options', array( |
|
373 | + 'id' => __('Donation ID', 'give'), |
|
374 | + 'amount' => __('Donation Amount', 'give'), |
|
375 | + 'post_date' => __('Donation Date', 'give'), |
|
376 | + 'first_name' => __('Donor First Name', 'give'), |
|
377 | + 'last_name' => __('Donor Last Name', 'give'), |
|
378 | + 'line1' => __('Address 1', 'give'), |
|
379 | + 'line2' => __('Address 2', 'give'), |
|
380 | + 'city' => __('City', 'give'), |
|
381 | + 'state' => __('State', 'give'), |
|
382 | 382 | 'country' => array( |
383 | - __( 'Country', 'give' ), |
|
384 | - __( 'County', 'give' ), |
|
385 | - __( 'Region', 'give' ), |
|
386 | - __( 'Province', 'give' ), |
|
383 | + __('Country', 'give'), |
|
384 | + __('County', 'give'), |
|
385 | + __('Region', 'give'), |
|
386 | + __('Province', 'give'), |
|
387 | 387 | ), |
388 | 388 | 'zip' => array( |
389 | - __( 'Zip', 'give' ), |
|
390 | - __( 'Postal Code', 'give' ), |
|
389 | + __('Zip', 'give'), |
|
390 | + __('Postal Code', 'give'), |
|
391 | 391 | ), |
392 | - 'email' => __( 'Donor Email', 'give' ), |
|
393 | - 'post_status' => __( 'Donation Status', 'give' ), |
|
394 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
395 | - 'notes' => __( 'Notes', 'give' ), |
|
396 | - 'mode' => __( 'Test Mode', 'give' ), |
|
397 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
398 | - ) ); |
|
392 | + 'email' => __('Donor Email', 'give'), |
|
393 | + 'post_status' => __('Donation Status', 'give'), |
|
394 | + 'gateway' => __('Payment Method', 'give'), |
|
395 | + 'notes' => __('Notes', 'give'), |
|
396 | + 'mode' => __('Test Mode', 'give'), |
|
397 | + 'post_meta' => __('Import as Meta', 'give'), |
|
398 | + )); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return array |
413 | 413 | */ |
414 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
415 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
416 | - 'user_id' => __( 'User ID', 'give' ), |
|
417 | - ) ); |
|
414 | + return (array) apply_filters('give_import_donor_options', array( |
|
415 | + 'donor_id' => __('Donor ID', 'give'), |
|
416 | + 'user_id' => __('User ID', 'give'), |
|
417 | + )); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -430,15 +430,15 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return array |
432 | 432 | */ |
433 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
433 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
434 | 434 | 'form_title' => array( |
435 | - __( 'Donation Form Title', 'give' ), |
|
436 | - __( 'Donation Form', 'give' ), |
|
435 | + __('Donation Form Title', 'give'), |
|
436 | + __('Donation Form', 'give'), |
|
437 | 437 | ), |
438 | - 'form_id' => __( 'Donation Form ID', 'give' ), |
|
439 | - 'form_level' => __( 'Donation Level', 'give' ), |
|
440 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
441 | - ) ); |
|
438 | + 'form_id' => __('Donation Form ID', 'give'), |
|
439 | + 'form_level' => __('Donation Level', 'give'), |
|
440 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
441 | + )); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return array |
453 | 453 | */ |
454 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
454 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
455 | 455 | /** |
456 | 456 | * Filter to modify delimiter of Import. |
457 | 457 | * |
@@ -460,19 +460,19 @@ discard block |
||
460 | 460 | * |
461 | 461 | * Return string $delimiter. |
462 | 462 | */ |
463 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
463 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
464 | 464 | |
465 | 465 | $raw_data = array(); |
466 | - $file_dir = get_attached_file( $file_id ); |
|
466 | + $file_dir = get_attached_file($file_id); |
|
467 | 467 | $count = 0; |
468 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
469 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
470 | - if ( $count >= $start && $count <= $end ) { |
|
468 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
469 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
470 | + if ($count >= $start && $count <= $end) { |
|
471 | 471 | $raw_data[] = $row; |
472 | 472 | } |
473 | - $count ++; |
|
473 | + $count++; |
|
474 | 474 | } |
475 | - fclose( $handle ); |
|
475 | + fclose($handle); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | return $raw_data; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return bool |
490 | 490 | */ |
491 | -function give_log_user_in_on_register_callback( $value ) { |
|
491 | +function give_log_user_in_on_register_callback($value) { |
|
492 | 492 | return false; |
493 | 493 | } |
494 | 494 | |
@@ -504,22 +504,22 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @return bool |
506 | 506 | */ |
507 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
508 | - $data = array_combine( $raw_key, $row_data ); |
|
507 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
508 | + $data = array_combine($raw_key, $row_data); |
|
509 | 509 | $price_id = false; |
510 | 510 | $customer_id = 0; |
511 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
511 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
512 | 512 | |
513 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
513 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
514 | 514 | |
515 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
515 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
516 | 516 | |
517 | 517 | // Here come the login function. |
518 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
519 | - if ( ! empty( $donor_data->id ) ) { |
|
520 | - if ( ! empty( $donor_data->user_id ) ) { |
|
518 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
519 | + if ( ! empty($donor_data->id)) { |
|
520 | + if ( ! empty($donor_data->user_id)) { |
|
521 | 521 | $customer_id = $donor_data->user_id; |
522 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
522 | + } elseif ( ! empty($data['user_id'])) { |
|
523 | 523 | $customer_id = $data['user_id']; |
524 | 524 | } |
525 | 525 | } else { |
@@ -527,95 +527,95 @@ discard block |
||
527 | 527 | } |
528 | 528 | |
529 | 529 | // get form data or register a form data. |
530 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
531 | - if ( false == $form ) { |
|
530 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
531 | + if (false == $form) { |
|
532 | 532 | return false; |
533 | 533 | } else { |
534 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
534 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
538 | 538 | $address = array( |
539 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
540 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
541 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
542 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
543 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
544 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
539 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
540 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
541 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
542 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
543 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
544 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
545 | 545 | ); |
546 | 546 | |
547 | 547 | //Create payment_data array |
548 | 548 | $payment_data = array( |
549 | 549 | 'donor_id' => $donor_data->id, |
550 | 550 | 'price' => $data['amount'], |
551 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
551 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
552 | 552 | 'currency' => give_get_currency(), |
553 | 553 | 'user_info' => array( |
554 | 554 | 'id' => $customer_id, |
555 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
556 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
557 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
555 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
556 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
557 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
558 | 558 | 'address' => $address, |
559 | 559 | ), |
560 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
561 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
560 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
561 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
562 | 562 | 'give_form_id' => (string) $form->get_ID(), |
563 | 563 | 'give_price_id' => $price_id, |
564 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
564 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
565 | 565 | 'user_email' => $data['email'], |
566 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
567 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
566 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
567 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
568 | 568 | ); |
569 | 569 | |
570 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
570 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
571 | 571 | |
572 | 572 | // Get the report |
573 | 573 | $report = give_import_donation_report(); |
574 | 574 | |
575 | 575 | // Check for duplicate code. |
576 | - if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) { |
|
577 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
576 | + if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) { |
|
577 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
578 | 578 | } else { |
579 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
580 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
581 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
582 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
583 | - $payment = give_insert_payment( $payment_data ); |
|
584 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
585 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
586 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
587 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
579 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
580 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
581 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
582 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
583 | + $payment = give_insert_payment($payment_data); |
|
584 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
585 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
586 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
587 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
588 | 588 | |
589 | - if ( $payment ) { |
|
589 | + if ($payment) { |
|
590 | 590 | |
591 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
591 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
592 | 592 | |
593 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
593 | + update_post_meta($payment, '_give_payment_import', true); |
|
594 | 594 | |
595 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
596 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
595 | + if ( ! empty($import_setting['csv'])) { |
|
596 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // Insert Notes. |
600 | - if ( ! empty( $data['notes'] ) ) { |
|
601 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
600 | + if ( ! empty($data['notes'])) { |
|
601 | + give_insert_payment_note($payment, $data['notes']); |
|
602 | 602 | } |
603 | 603 | |
604 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
605 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
606 | - foreach ( $meta_exists as $meta_exist ) { |
|
607 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
608 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
604 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
605 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
606 | + foreach ($meta_exists as $meta_exist) { |
|
607 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
608 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
612 | 612 | } else { |
613 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
613 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | // update the report |
618 | - give_import_donation_report_update( $report ); |
|
618 | + give_import_donation_report_update($report); |
|
619 | 619 | |
620 | 620 | return true; |
621 | 621 | } |
@@ -631,12 +631,12 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return Give_Donor |
633 | 633 | */ |
634 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
634 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
635 | 635 | $old_donor = $donor; |
636 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
637 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
638 | - $donor = new Give_Donor( $donor_id ); |
|
639 | - if ( ! empty( $donor->id ) ) { |
|
636 | + if ( ! empty($payment_data['donor_id'])) { |
|
637 | + $donor_id = absint($payment_data['donor_id']); |
|
638 | + $donor = new Give_Donor($donor_id); |
|
639 | + if ( ! empty($donor->id)) { |
|
640 | 640 | return $donor; |
641 | 641 | } |
642 | 642 | } |
@@ -649,12 +649,12 @@ discard block |
||
649 | 649 | * |
650 | 650 | * @since 1.8.13 |
651 | 651 | */ |
652 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
652 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
653 | 653 | // Update Give Customers purchase_count |
654 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
655 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
656 | - if ( ! empty( $donor_id ) ) { |
|
657 | - $donor = new Give_Donor( $donor_id ); |
|
654 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
655 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
656 | + if ( ! empty($donor_id)) { |
|
657 | + $donor = new Give_Donor($donor_id); |
|
658 | 658 | $donor->increase_purchase_count(); |
659 | 659 | } |
660 | 660 | } |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | * |
666 | 666 | * @since 1.8.13 |
667 | 667 | */ |
668 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
669 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
668 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
669 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
670 | 670 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
671 | 671 | } |
672 | 672 | |
@@ -678,11 +678,11 @@ discard block |
||
678 | 678 | * |
679 | 679 | * @since 1.8.13 |
680 | 680 | */ |
681 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
681 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
682 | 682 | $return = false; |
683 | - if ( ! empty( $data['post_date'] ) ) { |
|
684 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
685 | - $post_date = explode( '-', $post_date ); |
|
683 | + if ( ! empty($data['post_date'])) { |
|
684 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
685 | + $post_date = explode('-', $post_date); |
|
686 | 686 | $args = array( |
687 | 687 | 'post_type' => 'give_payment', |
688 | 688 | 'cache_results' => false, |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | 'meta_query' => array( |
704 | 704 | array( |
705 | 705 | 'key' => '_give_payment_total', |
706 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
706 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
707 | 707 | 'compare' => 'LIKE', |
708 | 708 | ), |
709 | 709 | array( |
@@ -720,9 +720,9 @@ discard block |
||
720 | 720 | ), |
721 | 721 | ); |
722 | 722 | |
723 | - $payments = new Give_Payments_Query( $args ); |
|
723 | + $payments = new Give_Payments_Query($args); |
|
724 | 724 | $donations = $payments->get_payments(); |
725 | - if ( ! empty( $donations ) ) { |
|
725 | + if ( ! empty($donations)) { |
|
726 | 726 | return true; |
727 | 727 | } |
728 | 728 | } |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | * |
740 | 740 | * @return void |
741 | 741 | */ |
742 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
742 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
743 | 743 | $current_user = wp_get_current_user(); |
744 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
744 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -753,14 +753,14 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return string URL |
755 | 755 | */ |
756 | -function give_import_page_url( $parameter = array() ) { |
|
756 | +function give_import_page_url($parameter = array()) { |
|
757 | 757 | $defalut_query_arg = array( |
758 | 758 | 'post_type' => 'give_forms', |
759 | 759 | 'page' => 'give-tools', |
760 | 760 | 'tab' => 'import', |
761 | 761 | 'importer-type' => 'import_donations', |
762 | 762 | ); |
763 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
763 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
764 | 764 | |
765 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
765 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
766 | 766 | } |
767 | 767 | \ No newline at end of file |