@@ -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,23 +123,23 @@ 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 | // Add payment bulk notice. |
131 | 131 | if ( |
132 | - current_user_can( 'edit_give_payments' ) |
|
133 | - && isset( $_GET['action'] ) |
|
134 | - && ! empty( $_GET['action'] ) |
|
135 | - && isset( $_GET['payment'] ) |
|
136 | - && ! empty( $_GET['payment'] ) |
|
132 | + current_user_can('edit_give_payments') |
|
133 | + && isset($_GET['action']) |
|
134 | + && ! empty($_GET['action']) |
|
135 | + && isset($_GET['payment']) |
|
136 | + && ! empty($_GET['payment']) |
|
137 | 137 | ) { |
138 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
138 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
139 | 139 | |
140 | - switch ( $_GET['action'] ) { |
|
140 | + switch ($_GET['action']) { |
|
141 | 141 | case 'delete': |
142 | - Give()->notices->register_notice( array( |
|
142 | + Give()->notices->register_notice(array( |
|
143 | 143 | 'id' => 'bulk_action_delete', |
144 | 144 | 'type' => 'updated', |
145 | 145 | 'description' => sprintf( |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | ), |
152 | 152 | $payment_count ), |
153 | 153 | 'show' => true, |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | |
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'resend-receipt': |
159 | - Give()->notices->register_notice( array( |
|
159 | + Give()->notices->register_notice(array( |
|
160 | 160 | 'id' => 'bulk_action_resend_receipt', |
161 | 161 | 'type' => 'updated', |
162 | 162 | 'description' => sprintf( |
@@ -169,196 +169,196 @@ discard block |
||
169 | 169 | $payment_count |
170 | 170 | ), |
171 | 171 | 'show' => true, |
172 | - ) ); |
|
172 | + )); |
|
173 | 173 | break; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Add give message notices. |
178 | - if ( ! empty( $_GET['give-message'] ) ) { |
|
178 | + if ( ! empty($_GET['give-message'])) { |
|
179 | 179 | // Donation reports errors. |
180 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
181 | - switch ( $_GET['give-message'] ) { |
|
180 | + if (current_user_can('view_give_reports')) { |
|
181 | + switch ($_GET['give-message']) { |
|
182 | 182 | case 'donation_deleted' : |
183 | - Give()->notices->register_notice( array( |
|
183 | + Give()->notices->register_notice(array( |
|
184 | 184 | 'id' => 'give-donation-deleted', |
185 | 185 | 'type' => 'updated', |
186 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
186 | + 'description' => __('The donation has been deleted.', 'give'), |
|
187 | 187 | 'show' => true, |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | break; |
190 | 190 | case 'email_sent' : |
191 | - Give()->notices->register_notice( array( |
|
191 | + Give()->notices->register_notice(array( |
|
192 | 192 | 'id' => 'give-payment-sent', |
193 | 193 | 'type' => 'updated', |
194 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
194 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
195 | 195 | 'show' => true, |
196 | - ) ); |
|
196 | + )); |
|
197 | 197 | break; |
198 | 198 | case 'refreshed-reports' : |
199 | - Give()->notices->register_notice( array( |
|
199 | + Give()->notices->register_notice(array( |
|
200 | 200 | 'id' => 'give-refreshed-reports', |
201 | 201 | 'type' => 'updated', |
202 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
202 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
203 | 203 | 'show' => true, |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | break; |
206 | 206 | case 'donation-note-deleted' : |
207 | - Give()->notices->register_notice( array( |
|
207 | + Give()->notices->register_notice(array( |
|
208 | 208 | 'id' => 'give-donation-note-deleted', |
209 | 209 | 'type' => 'updated', |
210 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
210 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
211 | 211 | 'show' => true, |
212 | - ) ); |
|
212 | + )); |
|
213 | 213 | break; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Give settings notices and errors. |
218 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
219 | - switch ( $_GET['give-message'] ) { |
|
218 | + if (current_user_can('manage_give_settings')) { |
|
219 | + switch ($_GET['give-message']) { |
|
220 | 220 | case 'settings-imported' : |
221 | - Give()->notices->register_notice( array( |
|
221 | + Give()->notices->register_notice(array( |
|
222 | 222 | 'id' => 'give-settings-imported', |
223 | 223 | 'type' => 'updated', |
224 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
224 | + 'description' => __('The settings have been imported.', 'give'), |
|
225 | 225 | 'show' => true, |
226 | - ) ); |
|
226 | + )); |
|
227 | 227 | break; |
228 | 228 | case 'api-key-generated' : |
229 | - Give()->notices->register_notice( array( |
|
229 | + Give()->notices->register_notice(array( |
|
230 | 230 | 'id' => 'give-api-key-generated', |
231 | 231 | 'type' => 'updated', |
232 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
232 | + 'description' => __('API keys have been generated.', 'give'), |
|
233 | 233 | 'show' => true, |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | break; |
236 | 236 | case 'api-key-exists' : |
237 | - Give()->notices->register_notice( array( |
|
237 | + Give()->notices->register_notice(array( |
|
238 | 238 | 'id' => 'give-api-key-exists', |
239 | 239 | 'type' => 'updated', |
240 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
240 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
241 | 241 | 'show' => true, |
242 | - ) ); |
|
242 | + )); |
|
243 | 243 | break; |
244 | 244 | case 'api-key-regenerated' : |
245 | - Give()->notices->register_notice( array( |
|
245 | + Give()->notices->register_notice(array( |
|
246 | 246 | 'id' => 'give-api-key-regenerated', |
247 | 247 | 'type' => 'updated', |
248 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
248 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
249 | 249 | 'show' => true, |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | break; |
252 | 252 | case 'api-key-revoked' : |
253 | - Give()->notices->register_notice( array( |
|
253 | + Give()->notices->register_notice(array( |
|
254 | 254 | 'id' => 'give-api-key-revoked', |
255 | 255 | 'type' => 'updated', |
256 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
256 | + 'description' => __('API keys have been revoked.', 'give'), |
|
257 | 257 | 'show' => true, |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | break; |
260 | 260 | case 'sent-test-email' : |
261 | - Give()->notices->register_notice( array( |
|
261 | + Give()->notices->register_notice(array( |
|
262 | 262 | 'id' => 'give-sent-test-email', |
263 | 263 | 'type' => 'updated', |
264 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
264 | + 'description' => __('The test email has been sent.', 'give'), |
|
265 | 265 | 'show' => true, |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | break; |
268 | 268 | case 'matched-success-failure-page': |
269 | - Give()->notices->register_notice( array( |
|
269 | + Give()->notices->register_notice(array( |
|
270 | 270 | 'id' => 'give-matched-success-failure-page', |
271 | 271 | 'type' => 'updated', |
272 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
272 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
273 | 273 | 'show' => true, |
274 | - ) ); |
|
274 | + )); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | // Payments errors. |
279 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
280 | - switch ( $_GET['give-message'] ) { |
|
279 | + if (current_user_can('edit_give_payments')) { |
|
280 | + switch ($_GET['give-message']) { |
|
281 | 281 | case 'note-added' : |
282 | - Give()->notices->register_notice( array( |
|
282 | + Give()->notices->register_notice(array( |
|
283 | 283 | 'id' => 'give-note-added', |
284 | 284 | 'type' => 'updated', |
285 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
285 | + 'description' => __('The donation note has been added.', 'give'), |
|
286 | 286 | 'show' => true, |
287 | - ) ); |
|
287 | + )); |
|
288 | 288 | break; |
289 | 289 | case 'payment-updated' : |
290 | - Give()->notices->register_notice( array( |
|
290 | + Give()->notices->register_notice(array( |
|
291 | 291 | 'id' => 'give-payment-updated', |
292 | 292 | 'type' => 'updated', |
293 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
293 | + 'description' => __('The donation has been updated.', 'give'), |
|
294 | 294 | 'show' => true, |
295 | - ) ); |
|
295 | + )); |
|
296 | 296 | break; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Donor Notices. |
301 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
302 | - switch ( $_GET['give-message'] ) { |
|
301 | + if (current_user_can('edit_give_payments')) { |
|
302 | + switch ($_GET['give-message']) { |
|
303 | 303 | case 'donor-deleted' : |
304 | - Give()->notices->register_notice( array( |
|
304 | + Give()->notices->register_notice(array( |
|
305 | 305 | 'id' => 'give-donor-deleted', |
306 | 306 | 'type' => 'updated', |
307 | - 'description' => __( 'The donor has been deleted.', 'give' ), |
|
307 | + 'description' => __('The donor has been deleted.', 'give'), |
|
308 | 308 | 'show' => true, |
309 | - ) ); |
|
309 | + )); |
|
310 | 310 | break; |
311 | 311 | |
312 | 312 | case 'email-added' : |
313 | - Give()->notices->register_notice( array( |
|
313 | + Give()->notices->register_notice(array( |
|
314 | 314 | 'id' => 'give-donor-email-added', |
315 | 315 | 'type' => 'updated', |
316 | - 'description' => __( 'Donor email added.', 'give' ), |
|
316 | + 'description' => __('Donor email added.', 'give'), |
|
317 | 317 | 'show' => true, |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | break; |
320 | 320 | |
321 | 321 | case 'email-removed' : |
322 | - Give()->notices->register_notice( array( |
|
322 | + Give()->notices->register_notice(array( |
|
323 | 323 | 'id' => 'give-donor-email-removed', |
324 | 324 | 'type' => 'updated', |
325 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
325 | + 'description' => __('Donor email removed.', 'give'), |
|
326 | 326 | 'show' => true, |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | break; |
329 | 329 | |
330 | 330 | case 'email-remove-failed' : |
331 | - Give()->notices->register_notice( array( |
|
331 | + Give()->notices->register_notice(array( |
|
332 | 332 | 'id' => 'give-donor-email-remove-failed', |
333 | 333 | 'type' => 'updated', |
334 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
334 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
335 | 335 | 'show' => true, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | break; |
338 | 338 | |
339 | 339 | case 'primary-email-updated' : |
340 | - Give()->notices->register_notice( array( |
|
340 | + Give()->notices->register_notice(array( |
|
341 | 341 | 'id' => 'give-donor-primary-email-updated', |
342 | 342 | 'type' => 'updated', |
343 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
343 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
344 | 344 | 'show' => true, |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | break; |
347 | 347 | |
348 | 348 | case 'primary-email-failed' : |
349 | - Give()->notices->register_notice( array( |
|
349 | + Give()->notices->register_notice(array( |
|
350 | 350 | 'id' => 'give-donor-primary-email-failed', |
351 | 351 | 'type' => 'updated', |
352 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
352 | + 'description' => __('Failed to set primary email.', 'give'), |
|
353 | 353 | 'show' => true, |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | break; |
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
361 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
362 | 362 | |
363 | 363 | |
364 | 364 | /** |
@@ -368,31 +368,30 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return bool |
370 | 370 | */ |
371 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
372 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
373 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
374 | - give_is_test_mode(); |
|
371 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
372 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
373 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
375 | 374 | |
376 | 375 | if ( |
377 | - ! current_user_can( 'view_give_reports' ) || |
|
376 | + ! current_user_can('view_give_reports') || |
|
378 | 377 | ! $is_test_mode |
379 | 378 | ) { |
380 | 379 | return false; |
381 | 380 | } |
382 | 381 | |
383 | 382 | // Add the main siteadmin menu item. |
384 | - $wp_admin_bar->add_menu( array( |
|
383 | + $wp_admin_bar->add_menu(array( |
|
385 | 384 | 'id' => 'give-test-notice', |
386 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
385 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
387 | 386 | 'parent' => 'top-secondary', |
388 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
389 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
390 | - ) ); |
|
387 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
388 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
389 | + )); |
|
391 | 390 | |
392 | 391 | return true; |
393 | 392 | } |
394 | 393 | |
395 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
394 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
396 | 395 | |
397 | 396 | /** |
398 | 397 | * Add Link to Import page in from donation archive and donation single page |
@@ -401,13 +400,13 @@ discard block |
||
401 | 400 | */ |
402 | 401 | function give_import_page_link_callback() { |
403 | 402 | ?> |
404 | - <a href="<?php echo esc_url( give_import_page_url() ); ?>" |
|
405 | - class="page-import-action page-title-action"><?php esc_html_e( 'Import Donations', 'give' ); ?></a> |
|
403 | + <a href="<?php echo esc_url(give_import_page_url()); ?>" |
|
404 | + class="page-import-action page-title-action"><?php esc_html_e('Import Donations', 'give'); ?></a> |
|
406 | 405 | |
407 | 406 | <style type="text/css"> |
408 | 407 | <?php |
409 | 408 | // Check if view donation single page only. |
410 | - if ( ! empty( $_REQUEST['view'] ) && 'view-payment-details' === (string) give_clean( $_REQUEST['view'] ) && 'give-payment-history' === give_clean( $_REQUEST['page'] ) ) { |
|
409 | + if ( ! empty($_REQUEST['view']) && 'view-payment-details' === (string) give_clean($_REQUEST['view']) && 'give-payment-history' === give_clean($_REQUEST['page'])) { |
|
411 | 410 | ?> |
412 | 411 | .wrap #transaction-details-heading { |
413 | 412 | display: inline-block; |
@@ -429,7 +428,7 @@ discard block |
||
429 | 428 | } |
430 | 429 | |
431 | 430 | |
432 | -add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 ); |
|
431 | +add_action('give_payments_page_top', 'give_import_page_link_callback', 11); |
|
433 | 432 | |
434 | 433 | /** |
435 | 434 | * Load donation import ajax callback |
@@ -441,9 +440,9 @@ discard block |
||
441 | 440 | */ |
442 | 441 | function give_donation_import_callback() { |
443 | 442 | $import_setting = array(); |
444 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
443 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
445 | 444 | |
446 | - parse_str( $fields ); |
|
445 | + parse_str($fields); |
|
447 | 446 | |
448 | 447 | $import_setting['create_user'] = $create_user; |
449 | 448 | $import_setting['mode'] = $mode; |
@@ -452,54 +451,54 @@ discard block |
||
452 | 451 | $import_setting['delete_csv'] = $delete_csv; |
453 | 452 | |
454 | 453 | // Parent key id. |
455 | - $main_key = maybe_unserialize( $main_key ); |
|
456 | - |
|
457 | - $current = absint( $_REQUEST['current'] ); |
|
458 | - $total_ajax = absint( $_REQUEST['total_ajax'] ); |
|
459 | - $start = absint( $_REQUEST['start'] ); |
|
460 | - $end = absint( $_REQUEST['end'] ); |
|
461 | - $next = absint( $_REQUEST['next'] ); |
|
462 | - $total = absint( $_REQUEST['total'] ); |
|
463 | - $per_page = absint( $_REQUEST['per_page'] ); |
|
464 | - if ( empty( $delimiter ) ) { |
|
454 | + $main_key = maybe_unserialize($main_key); |
|
455 | + |
|
456 | + $current = absint($_REQUEST['current']); |
|
457 | + $total_ajax = absint($_REQUEST['total_ajax']); |
|
458 | + $start = absint($_REQUEST['start']); |
|
459 | + $end = absint($_REQUEST['end']); |
|
460 | + $next = absint($_REQUEST['next']); |
|
461 | + $total = absint($_REQUEST['total']); |
|
462 | + $per_page = absint($_REQUEST['per_page']); |
|
463 | + if (empty($delimiter)) { |
|
465 | 464 | $delimiter = ','; |
466 | 465 | } |
467 | 466 | |
468 | 467 | // processing done here. |
469 | - $raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter ); |
|
470 | - $raw_key = maybe_unserialize( $mapto ); |
|
468 | + $raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter); |
|
469 | + $raw_key = maybe_unserialize($mapto); |
|
471 | 470 | |
472 | 471 | //Prevent normal emails |
473 | - remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
474 | - remove_action( 'give_insert_user', 'give_new_user_notification', 10 ); |
|
475 | - remove_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
472 | + remove_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
473 | + remove_action('give_insert_user', 'give_new_user_notification', 10); |
|
474 | + remove_action('give_insert_payment', 'give_payment_save_page_data'); |
|
476 | 475 | |
477 | - foreach ( $raw_data as $row_data ) { |
|
478 | - give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting ); |
|
476 | + foreach ($raw_data as $row_data) { |
|
477 | + give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting); |
|
479 | 478 | } |
480 | 479 | |
481 | 480 | // Check if function exists or not. |
482 | - if ( function_exists( 'give_payment_save_page_data' ) ) { |
|
483 | - add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
481 | + if (function_exists('give_payment_save_page_data')) { |
|
482 | + add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
484 | 483 | } |
485 | - add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
486 | - add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
484 | + add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
485 | + add_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
487 | 486 | |
488 | - if ( $next == false ) { |
|
487 | + if ($next == false) { |
|
489 | 488 | $json_data = array( |
490 | 489 | 'success' => true, |
491 | - 'message' => __( 'All donation uploaded successfully!', 'give' ), |
|
490 | + 'message' => __('All donation uploaded successfully!', 'give'), |
|
492 | 491 | ); |
493 | 492 | } else { |
494 | 493 | $index_start = $start; |
495 | 494 | $index_end = $end; |
496 | 495 | $last = false; |
497 | 496 | $next = true; |
498 | - if ( $next ) { |
|
497 | + if ($next) { |
|
499 | 498 | $index_start = $index_start + $per_page; |
500 | - $index_end = $per_page + ( $index_start - 1 ); |
|
499 | + $index_end = $per_page + ($index_start - 1); |
|
501 | 500 | } |
502 | - if ( $index_end >= $total ) { |
|
501 | + if ($index_end >= $total) { |
|
503 | 502 | $index_end = $total; |
504 | 503 | $last = true; |
505 | 504 | } |
@@ -513,26 +512,26 @@ discard block |
||
513 | 512 | ); |
514 | 513 | } |
515 | 514 | |
516 | - $url = give_import_page_url( array( |
|
515 | + $url = give_import_page_url(array( |
|
517 | 516 | 'step' => '4', |
518 | 517 | 'csv' => $csv, |
519 | 518 | 'total' => $total, |
520 | 519 | 'delete_csv' => $import_setting['delete_csv'], |
521 | - 'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ), |
|
522 | - ) ); |
|
520 | + 'success' => (isset($json_data['success']) ? $json_data['success'] : ''), |
|
521 | + )); |
|
523 | 522 | $json_data['url'] = $url; |
524 | 523 | |
525 | - $current ++; |
|
524 | + $current++; |
|
526 | 525 | $json_data['current'] = $current; |
527 | 526 | |
528 | - $percentage = ( 100 / ( $total_ajax + 1 ) ) * $current; |
|
527 | + $percentage = (100 / ($total_ajax + 1)) * $current; |
|
529 | 528 | $json_data['percentage'] = $percentage; |
530 | 529 | |
531 | - $json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields ); |
|
532 | - wp_die( json_encode( $json_data ) ); |
|
530 | + $json_data = apply_filters('give_import_ajax_responces', $json_data, $fields); |
|
531 | + wp_die(json_encode($json_data)); |
|
533 | 532 | } |
534 | 533 | |
535 | -add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' ); |
|
534 | +add_action('wp_ajax_give_donation_import', 'give_donation_import_callback'); |
|
536 | 535 | |
537 | 536 | |
538 | 537 | /** |
@@ -545,7 +544,7 @@ discard block |
||
545 | 544 | $blank_slate->init(); |
546 | 545 | } |
547 | 546 | |
548 | -add_action( 'current_screen', 'give_blank_slate' ); |
|
547 | +add_action('current_screen', 'give_blank_slate'); |
|
549 | 548 | |
550 | 549 | /** |
551 | 550 | * Get Array of WP User Roles. |
@@ -558,8 +557,8 @@ discard block |
||
558 | 557 | $user_roles = array(); |
559 | 558 | |
560 | 559 | // Loop through User Roles. |
561 | - foreach ( get_editable_roles() as $role_name => $role_info ): |
|
562 | - $user_roles[ $role_name ] = $role_info['name']; |
|
560 | + foreach (get_editable_roles() as $role_name => $role_info): |
|
561 | + $user_roles[$role_name] = $role_info['name']; |
|
563 | 562 | endforeach; |
564 | 563 | |
565 | 564 | return $user_roles; |