@@ -98,7 +98,7 @@ |
||
98 | 98 | * |
99 | 99 | * @since 1.8 |
100 | 100 | * |
101 | - * @return bool |
|
101 | + * @return false|null |
|
102 | 102 | */ |
103 | 103 | function give_redirect_to_clean_url_admin_pages() { |
104 | 104 | // Give admin pages. |
@@ -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,8 +428,8 @@ discard block |
||
429 | 428 | } |
430 | 429 | |
431 | 430 | |
432 | -add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 ); |
|
433 | -add_action( 'give_view_order_details_before', 'give_import_page_link_callback', 11 ); |
|
431 | +add_action('give_payments_page_top', 'give_import_page_link_callback', 11); |
|
432 | +add_action('give_view_order_details_before', 'give_import_page_link_callback', 11); |
|
434 | 433 | |
435 | 434 | /** |
436 | 435 | * Load donation import ajax callback |
@@ -442,9 +441,9 @@ discard block |
||
442 | 441 | */ |
443 | 442 | function give_donation_import_callback() { |
444 | 443 | $import_setting = array(); |
445 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
444 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
446 | 445 | |
447 | - parse_str( $fields ); |
|
446 | + parse_str($fields); |
|
448 | 447 | |
449 | 448 | $import_setting['create_user'] = $create_user; |
450 | 449 | $import_setting['mode'] = $mode; |
@@ -453,54 +452,54 @@ discard block |
||
453 | 452 | $import_setting['delete_csv'] = $delete_csv; |
454 | 453 | |
455 | 454 | // Parent key id. |
456 | - $main_key = maybe_unserialize( $main_key ); |
|
457 | - |
|
458 | - $current = absint( $_REQUEST['current'] ); |
|
459 | - $total_ajax = absint( $_REQUEST['total_ajax'] ); |
|
460 | - $start = absint( $_REQUEST['start'] ); |
|
461 | - $end = absint( $_REQUEST['end'] ); |
|
462 | - $next = absint( $_REQUEST['next'] ); |
|
463 | - $total = absint( $_REQUEST['total'] ); |
|
464 | - $per_page = absint( $_REQUEST['per_page'] ); |
|
465 | - if ( empty( $delimiter ) ) { |
|
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)) { |
|
466 | 465 | $delimiter = ','; |
467 | 466 | } |
468 | 467 | |
469 | 468 | // processing done here. |
470 | - $raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter ); |
|
471 | - $raw_key = maybe_unserialize( $mapto ); |
|
469 | + $raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter); |
|
470 | + $raw_key = maybe_unserialize($mapto); |
|
472 | 471 | |
473 | 472 | //Prevent normal emails |
474 | - remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
475 | - remove_action( 'give_insert_user', 'give_new_user_notification', 10 ); |
|
476 | - remove_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
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'); |
|
477 | 476 | |
478 | - foreach ( $raw_data as $row_data ) { |
|
479 | - give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting ); |
|
477 | + foreach ($raw_data as $row_data) { |
|
478 | + give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting); |
|
480 | 479 | } |
481 | 480 | |
482 | 481 | // Check if function exists or not. |
483 | - if ( function_exists( 'give_payment_save_page_data' ) ) { |
|
484 | - add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
482 | + if (function_exists('give_payment_save_page_data')) { |
|
483 | + add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
485 | 484 | } |
486 | - add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
487 | - add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
485 | + add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
486 | + add_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
488 | 487 | |
489 | - if ( $next == false ) { |
|
488 | + if ($next == false) { |
|
490 | 489 | $json_data = array( |
491 | 490 | 'success' => true, |
492 | - 'message' => __( 'All donation uploaded successfully!', 'give' ), |
|
491 | + 'message' => __('All donation uploaded successfully!', 'give'), |
|
493 | 492 | ); |
494 | 493 | } else { |
495 | 494 | $index_start = $start; |
496 | 495 | $index_end = $end; |
497 | 496 | $last = false; |
498 | 497 | $next = true; |
499 | - if ( $next ) { |
|
498 | + if ($next) { |
|
500 | 499 | $index_start = $index_start + $per_page; |
501 | - $index_end = $per_page + ( $index_start - 1 ); |
|
500 | + $index_end = $per_page + ($index_start - 1); |
|
502 | 501 | } |
503 | - if ( $index_end >= $total ) { |
|
502 | + if ($index_end >= $total) { |
|
504 | 503 | $index_end = $total; |
505 | 504 | $last = true; |
506 | 505 | } |
@@ -514,26 +513,26 @@ discard block |
||
514 | 513 | ); |
515 | 514 | } |
516 | 515 | |
517 | - $url = give_import_page_url( array( |
|
516 | + $url = give_import_page_url(array( |
|
518 | 517 | 'step' => '4', |
519 | 518 | 'csv' => $csv, |
520 | 519 | 'total' => $total, |
521 | 520 | 'delete_csv' => $import_setting['delete_csv'], |
522 | - 'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ), |
|
523 | - ) ); |
|
521 | + 'success' => (isset($json_data['success']) ? $json_data['success'] : ''), |
|
522 | + )); |
|
524 | 523 | $json_data['url'] = $url; |
525 | 524 | |
526 | - $current ++; |
|
525 | + $current++; |
|
527 | 526 | $json_data['current'] = $current; |
528 | 527 | |
529 | - $percentage = ( 100 / ( $total_ajax + 1 ) ) * $current; |
|
528 | + $percentage = (100 / ($total_ajax + 1)) * $current; |
|
530 | 529 | $json_data['percentage'] = $percentage; |
531 | 530 | |
532 | - $json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields ); |
|
533 | - wp_die( json_encode( $json_data ) ); |
|
531 | + $json_data = apply_filters('give_import_ajax_responces', $json_data, $fields); |
|
532 | + wp_die(json_encode($json_data)); |
|
534 | 533 | } |
535 | 534 | |
536 | -add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' ); |
|
535 | +add_action('wp_ajax_give_donation_import', 'give_donation_import_callback'); |
|
537 | 536 | |
538 | 537 | |
539 | 538 | /** |
@@ -546,7 +545,7 @@ discard block |
||
546 | 545 | $blank_slate->init(); |
547 | 546 | } |
548 | 547 | |
549 | -add_action( 'current_screen', 'give_blank_slate' ); |
|
548 | +add_action('current_screen', 'give_blank_slate'); |
|
550 | 549 | |
551 | 550 | /** |
552 | 551 | * Get Array of WP User Roles. |
@@ -559,8 +558,8 @@ discard block |
||
559 | 558 | $user_roles = array(); |
560 | 559 | |
561 | 560 | // Loop through User Roles. |
562 | - foreach ( get_editable_roles() as $role_name => $role_info ): |
|
563 | - $user_roles[ $role_name ] = $role_info['name']; |
|
561 | + foreach (get_editable_roles() as $role_name => $role_info): |
|
562 | + $user_roles[$role_name] = $role_info['name']; |
|
564 | 563 | endforeach; |
565 | 564 | |
566 | 565 | return $user_roles; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
78 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,28 +196,28 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | 204 | // Check for PayPal IPN Notifications and update data based on it. |
205 | - $current_timestamp = current_time( 'timestamp' ); |
|
205 | + $current_timestamp = current_time('timestamp'); |
|
206 | 206 | $paypal_ipn_vars = array( |
207 | - 'auth_status' => ( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
207 | + 'auth_status' => ($api_response['body']) ? $api_response['body'] : 'N/A', |
|
208 | 208 | 'transaction_id' => $encoded_data_array['txn_id'], |
209 | 209 | 'payment_id' => $payment_id, |
210 | 210 | ); |
211 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
212 | - give_insert_payment_note( $payment_id, sprintf( |
|
213 | - __( 'Last IPN received on %s at %s', 'give' ), |
|
214 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
215 | - date_i18n( 'H:i', $current_timestamp ) |
|
211 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
212 | + give_insert_payment_note($payment_id, sprintf( |
|
213 | + __('Last IPN received on %s at %s', 'give'), |
|
214 | + date_i18n('m/d/Y', $current_timestamp), |
|
215 | + date_i18n('H:i', $current_timestamp) |
|
216 | 216 | ) |
217 | 217 | ); |
218 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
218 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
219 | 219 | |
220 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
220 | + if (has_action('give_paypal_'.$txn_type)) { |
|
221 | 221 | /** |
222 | 222 | * Fires while processing PayPal IPN $txn_type. |
223 | 223 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $encoded_data_array Encoded data. |
229 | 229 | * @param int $payment_id Payment id. |
230 | 230 | */ |
231 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
231 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
232 | 232 | } else { |
233 | 233 | /** |
234 | 234 | * Fires while process PayPal IPN. |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param array $encoded_data_array Encoded data. |
241 | 241 | * @param int $payment_id Payment id. |
242 | 242 | */ |
243 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
243 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
244 | 244 | } |
245 | 245 | exit; |
246 | 246 | } |
247 | 247 | |
248 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
248 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Process web accept (one time) payment IPNs. |
@@ -257,99 +257,99 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
260 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
261 | 261 | |
262 | 262 | // Only allow through these transaction types. |
263 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
263 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Need $payment_id to continue. |
268 | - if ( empty( $payment_id ) ) { |
|
268 | + if (empty($payment_id)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Collect donation payment details. |
273 | 273 | $paypal_amount = $data['mc_gross']; |
274 | - $payment_status = strtolower( $data['payment_status'] ); |
|
275 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
276 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
277 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
274 | + $payment_status = strtolower($data['payment_status']); |
|
275 | + $currency_code = strtolower($data['mc_currency']); |
|
276 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
277 | + $payment_meta = give_get_payment_meta($payment_id); |
|
278 | 278 | |
279 | 279 | // Must be a PayPal standard IPN. |
280 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
280 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | 284 | // Verify payment recipient |
285 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
285 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
286 | 286 | |
287 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
287 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
289 | + give_update_payment_status($payment_id, 'failed'); |
|
290 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
291 | 291 | |
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Verify payment currency. |
296 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
296 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
297 | 297 | |
298 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
300 | - give_update_payment_status( $payment_id, 'failed' ); |
|
301 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
298 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
300 | + give_update_payment_status($payment_id, 'failed'); |
|
301 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
302 | 302 | |
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Process refunds & reversed. |
307 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
308 | - give_process_paypal_refund( $data, $payment_id ); |
|
307 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
308 | + give_process_paypal_refund($data, $payment_id); |
|
309 | 309 | |
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Only complete payments once. |
314 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
314 | + if ('publish' === get_post_status($payment_id)) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Retrieve the total donation amount (before PayPal). |
319 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
319 | + $payment_amount = give_get_payment_amount($payment_id); |
|
320 | 320 | |
321 | 321 | // Check that the donation PP and local db amounts match. |
322 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
322 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
323 | 323 | // The prices don't match |
324 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
326 | - give_update_payment_status( $payment_id, 'failed' ); |
|
327 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
324 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
326 | + give_update_payment_status($payment_id, 'failed'); |
|
327 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
328 | 328 | |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Process completed donations. |
333 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
333 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
334 | 334 | |
335 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
337 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
338 | - give_update_payment_status( $payment_id, 'publish' ); |
|
335 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
337 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
338 | + give_update_payment_status($payment_id, 'publish'); |
|
339 | 339 | |
340 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
340 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
341 | 341 | |
342 | 342 | // Look for possible pending reasons, such as an echeck. |
343 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
343 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
344 | 344 | |
345 | - if ( ! empty( $note ) ) { |
|
346 | - give_insert_payment_note( $payment_id, $note ); |
|
345 | + if ( ! empty($note)) { |
|
346 | + give_insert_payment_note($payment_id, $note); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
352 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Process PayPal IPN Refunds |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
364 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
365 | 365 | |
366 | 366 | // Collect payment details. |
367 | - if ( empty( $payment_id ) ) { |
|
367 | + if (empty($payment_id)) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Only refund payments once. |
372 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
372 | + if ('refunded' === get_post_status($payment_id)) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | $refund_amount = $data['payment_gross'] * - 1; |
378 | 378 | |
379 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
379 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
380 | 380 | |
381 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
381 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
383 | 383 | |
384 | 384 | return; // This is a partial refund |
385 | 385 | |
386 | 386 | } |
387 | 387 | |
388 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
390 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
392 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
388 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
390 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
392 | + give_update_payment_status($payment_id, 'refunded'); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string |
403 | 403 | */ |
404 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
404 | +function give_get_paypal_redirect($ssl_check = false) { |
|
405 | 405 | |
406 | - if ( is_ssl() || ! $ssl_check ) { |
|
406 | + if (is_ssl() || ! $ssl_check) { |
|
407 | 407 | $protocol = 'https://'; |
408 | 408 | } else { |
409 | 409 | $protocol = 'http://'; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Check the current payment mode |
413 | - if ( give_is_test_mode() ) { |
|
413 | + if (give_is_test_mode()) { |
|
414 | 414 | // Test mode |
415 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
415 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
416 | 416 | } else { |
417 | 417 | // Live mode |
418 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
418 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
419 | 419 | } |
420 | 420 | |
421 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
421 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | * @return string |
429 | 429 | */ |
430 | 430 | function give_get_paypal_page_style() { |
431 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
431 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
432 | 432 | |
433 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
433 | + return apply_filters('give_paypal_page_style', $page_style); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -444,26 +444,26 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string |
446 | 446 | */ |
447 | -function give_paypal_success_page_content( $content ) { |
|
447 | +function give_paypal_success_page_content($content) { |
|
448 | 448 | |
449 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
449 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
450 | 450 | return $content; |
451 | 451 | } |
452 | 452 | |
453 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
453 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
454 | 454 | |
455 | - if ( ! $payment_id ) { |
|
455 | + if ( ! $payment_id) { |
|
456 | 456 | $session = give_get_purchase_session(); |
457 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
457 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
458 | 458 | } |
459 | 459 | |
460 | - $payment = get_post( $payment_id ); |
|
461 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
460 | + $payment = get_post($payment_id); |
|
461 | + if ($payment && 'pending' === $payment->post_status) { |
|
462 | 462 | |
463 | 463 | // Payment is still pending so show processing indicator to fix the race condition. |
464 | 464 | ob_start(); |
465 | 465 | |
466 | - give_get_template_part( 'payment', 'processing' ); |
|
466 | + give_get_template_part('payment', 'processing'); |
|
467 | 467 | |
468 | 468 | $content = ob_get_clean(); |
469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
476 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return string A link to the PayPal transaction details |
487 | 487 | */ |
488 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
488 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
489 | 489 | |
490 | 490 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
491 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
491 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
492 | 492 | |
493 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
493 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
497 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
498 | 498 | |
499 | 499 | |
500 | 500 | /** |
@@ -506,64 +506,64 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string |
508 | 508 | */ |
509 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
509 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
510 | 510 | |
511 | 511 | $note = ''; |
512 | 512 | |
513 | - switch ( $pending_reason ) { |
|
513 | + switch ($pending_reason) { |
|
514 | 514 | |
515 | 515 | case 'echeck' : |
516 | 516 | |
517 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
517 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
518 | 518 | |
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'address' : |
522 | 522 | |
523 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
523 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
524 | 524 | |
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'intl' : |
528 | 528 | |
529 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
529 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
530 | 530 | |
531 | 531 | break; |
532 | 532 | |
533 | 533 | case 'multi-currency' : |
534 | 534 | |
535 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
535 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
536 | 536 | |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'paymentreview' : |
540 | 540 | case 'regulatory_review' : |
541 | 541 | |
542 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
542 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
543 | 543 | |
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'unilateral' : |
547 | 547 | |
548 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
548 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
549 | 549 | |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case 'upgrade' : |
553 | 553 | |
554 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
554 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'verify' : |
559 | 559 | |
560 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
560 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'other' : |
565 | 565 | |
566 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
566 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
567 | 567 | |
568 | 568 | break; |
569 | 569 | |
@@ -581,49 +581,49 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return mixed|string |
583 | 583 | */ |
584 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
584 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
585 | 585 | // Only send to PayPal if the pending payment is created successfully. |
586 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
586 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
587 | 587 | |
588 | 588 | // Get the success url. |
589 | - $return_url = add_query_arg( array( |
|
589 | + $return_url = add_query_arg(array( |
|
590 | 590 | 'payment-confirmation' => 'paypal', |
591 | 591 | 'payment-id' => $payment_id, |
592 | 592 | |
593 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
593 | + ), get_permalink(give_get_option('success_page'))); |
|
594 | 594 | |
595 | 595 | // Get the PayPal redirect uri. |
596 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
596 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
597 | 597 | |
598 | 598 | // Item name. |
599 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
599 | + $item_name = give_build_paypal_item_title($payment_data); |
|
600 | 600 | |
601 | 601 | // Setup PayPal API params. |
602 | 602 | $paypal_args = array( |
603 | - 'business' => give_get_option( 'paypal_email', false ), |
|
603 | + 'business' => give_get_option('paypal_email', false), |
|
604 | 604 | 'first_name' => $payment_data['user_info']['first_name'], |
605 | 605 | 'last_name' => $payment_data['user_info']['last_name'], |
606 | 606 | 'email' => $payment_data['user_email'], |
607 | 607 | 'invoice' => $payment_data['purchase_key'], |
608 | 608 | 'amount' => $payment_data['price'], |
609 | - 'item_name' => stripslashes( $item_name ), |
|
609 | + 'item_name' => stripslashes($item_name), |
|
610 | 610 | 'no_shipping' => '1', |
611 | 611 | 'shipping' => '0', |
612 | 612 | 'no_note' => '1', |
613 | 613 | 'currency_code' => give_get_currency(), |
614 | - 'charset' => get_bloginfo( 'charset' ), |
|
614 | + 'charset' => get_bloginfo('charset'), |
|
615 | 615 | 'custom' => $payment_id, |
616 | 616 | 'rm' => '2', |
617 | 617 | 'return' => $return_url, |
618 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
618 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
619 | 619 | 'notify_url' => $listener_url, |
620 | 620 | 'page_style' => give_get_paypal_page_style(), |
621 | - 'cbt' => get_bloginfo( 'name' ), |
|
621 | + 'cbt' => get_bloginfo('name'), |
|
622 | 622 | 'bn' => 'givewp_SP', |
623 | 623 | ); |
624 | 624 | |
625 | 625 | // Add user address if present. |
626 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
626 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
627 | 627 | $default_address = array( |
628 | 628 | 'line1' => '', |
629 | 629 | 'line2' => '', |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'country' => '', |
634 | 634 | ); |
635 | 635 | |
636 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
636 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
637 | 637 | |
638 | 638 | $paypal_args['address1'] = $address['line1']; |
639 | 639 | $paypal_args['address2'] = $address['line2']; |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * @param array $paypal_args |
655 | 655 | * @param array $payment_data |
656 | 656 | */ |
657 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
657 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
658 | 658 | |
659 | 659 | // Build query. |
660 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
660 | + $paypal_redirect .= http_build_query($paypal_args); |
|
661 | 661 | |
662 | 662 | // Fix for some sites that encode the entities. |
663 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
663 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
664 | 664 | |
665 | 665 | return $paypal_redirect; |
666 | 666 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function give_get_paypal_button_type() { |
676 | 676 | // paypal_button_type can be donation or standard. |
677 | 677 | $paypal_button_type = '_donations'; |
678 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
678 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
679 | 679 | $paypal_button_type = '_xclick'; |
680 | 680 | } |
681 | 681 | |
@@ -692,30 +692,30 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return string |
694 | 694 | */ |
695 | -function give_build_paypal_item_title( $payment_data ) { |
|
696 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
695 | +function give_build_paypal_item_title($payment_data) { |
|
696 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
697 | 697 | $item_name = $payment_data['post_data']['give-form-title']; |
698 | 698 | |
699 | 699 | // Verify has variable prices. |
700 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
700 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
701 | 701 | |
702 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
703 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
702 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
703 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
704 | 704 | |
705 | 705 | // Donation given doesn't match selected level (must be a custom amount). |
706 | - if ( $price_level_amount != give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
707 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
706 | + if ($price_level_amount != give_maybe_sanitize_amount($payment_data['price'])) { |
|
707 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
708 | 708 | // user custom amount text if any, fallback to default if not. |
709 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
709 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
710 | 710 | |
711 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
712 | - $item_name .= ' - ' . $item_price_level_text; |
|
711 | + } elseif ( ! empty($item_price_level_text)) { |
|
712 | + $item_name .= ' - '.$item_price_level_text; |
|
713 | 713 | } |
714 | 714 | } // End if(). |
715 | - elseif ( give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
716 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
715 | + elseif (give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['price'])) { |
|
716 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
717 | 717 | // user custom amount text if any, fallback to default if not. |
718 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
718 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | return $item_name; |
@@ -39,8 +39,8 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
42 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | + && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
44 | 44 | ) { |
45 | 45 | |
46 | 46 | $forms_singular_option = give_get_option( 'forms_singular' ); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
37 | + if ( ! function_exists('is_plugin_active')) { |
|
38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
44 | 44 | ) { |
45 | 45 | |
46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
48 | 48 | |
49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
50 | 50 | if ( |
51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
53 | 53 | ) { |
54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,36 +23,36 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | // Give Forms single post and archive options. |
26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
28 | 28 | |
29 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
29 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
30 | 30 | // Support for old 'GIVE_FORMS_SLUG' constant |
31 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
31 | + if (defined('GIVE_FORMS_SLUG')) { |
|
32 | 32 | $give_forms_slug = GIVE_FORMS_SLUG; |
33 | 33 | } |
34 | 34 | |
35 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
35 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | 36 | 'slug' => $give_forms_slug, |
37 | 37 | 'with_front' => false, |
38 | 38 | ); |
39 | 39 | |
40 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
41 | - 'name' => __( 'Donation Forms', 'give' ), |
|
42 | - 'singular_name' => __( 'Form', 'give' ), |
|
43 | - 'add_new' => __( 'Add Form', 'give' ), |
|
44 | - 'add_new_item' => __( 'Add New Donation Form', 'give' ), |
|
45 | - 'edit_item' => __( 'Edit Donation Form', 'give' ), |
|
46 | - 'new_item' => __( 'New Form', 'give' ), |
|
47 | - 'all_items' => __( 'All Forms', 'give' ), |
|
48 | - 'view_item' => __( 'View Form', 'give' ), |
|
49 | - 'search_items' => __( 'Search Forms', 'give' ), |
|
50 | - 'not_found' => __( 'No forms found.', 'give' ), |
|
51 | - 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), |
|
40 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
41 | + 'name' => __('Donation Forms', 'give'), |
|
42 | + 'singular_name' => __('Form', 'give'), |
|
43 | + 'add_new' => __('Add Form', 'give'), |
|
44 | + 'add_new_item' => __('Add New Donation Form', 'give'), |
|
45 | + 'edit_item' => __('Edit Donation Form', 'give'), |
|
46 | + 'new_item' => __('New Form', 'give'), |
|
47 | + 'all_items' => __('All Forms', 'give'), |
|
48 | + 'view_item' => __('View Form', 'give'), |
|
49 | + 'search_items' => __('Search Forms', 'give'), |
|
50 | + 'not_found' => __('No forms found.', 'give'), |
|
51 | + 'not_found_in_trash' => __('No forms found in Trash.', 'give'), |
|
52 | 52 | 'parent_item_colon' => '', |
53 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
54 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), |
|
55 | - ) ); |
|
53 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
54 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')), |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | // Default give_forms supports. |
58 | 58 | $give_form_supports = array( |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Has the user disabled the excerpt? |
67 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
68 | - unset( $give_form_supports[2] ); |
|
67 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
68 | + unset($give_form_supports[2]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Has user disabled the featured image? |
72 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
73 | - unset( $give_form_supports[1] ); |
|
74 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
72 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
73 | + unset($give_form_supports[1]); |
|
74 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $give_forms_args = array( |
@@ -86,42 +86,42 @@ discard block |
||
86 | 86 | 'has_archive' => $give_forms_archives, |
87 | 87 | 'menu_icon' => 'dashicons-give', |
88 | 88 | 'hierarchical' => false, |
89 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
89 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
90 | 90 | ); |
91 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
91 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
92 | 92 | |
93 | 93 | /** Donation Post Type */ |
94 | 94 | $payment_labels = array( |
95 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
96 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
97 | - 'add_new' => __( 'Add New', 'give' ), |
|
98 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
99 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
100 | - 'new_item' => __( 'New Donation', 'give' ), |
|
101 | - 'all_items' => __( 'All Donations', 'give' ), |
|
102 | - 'view_item' => __( 'View Donation', 'give' ), |
|
103 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
104 | - 'not_found' => __( 'No donations found.', 'give' ), |
|
105 | - 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
|
95 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
96 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
97 | + 'add_new' => __('Add New', 'give'), |
|
98 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
99 | + 'edit_item' => __('Edit Donation', 'give'), |
|
100 | + 'new_item' => __('New Donation', 'give'), |
|
101 | + 'all_items' => __('All Donations', 'give'), |
|
102 | + 'view_item' => __('View Donation', 'give'), |
|
103 | + 'search_items' => __('Search Donations', 'give'), |
|
104 | + 'not_found' => __('No donations found.', 'give'), |
|
105 | + 'not_found_in_trash' => __('No donations found in Trash.', 'give'), |
|
106 | 106 | 'parent_item_colon' => '', |
107 | - 'menu_name' => __( 'Donations', 'give' ), |
|
107 | + 'menu_name' => __('Donations', 'give'), |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | $payment_args = array( |
111 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
111 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
112 | 112 | 'public' => false, |
113 | 113 | 'query_var' => false, |
114 | 114 | 'rewrite' => false, |
115 | 115 | 'map_meta_cap' => true, |
116 | 116 | 'capability_type' => 'give_payment', |
117 | - 'supports' => array( 'title' ), |
|
117 | + 'supports' => array('title'), |
|
118 | 118 | 'can_export' => true, |
119 | 119 | ); |
120 | - register_post_type( 'give_payment', $payment_args ); |
|
120 | + register_post_type('give_payment', $payment_args); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
124 | +add_action('init', 'give_setup_post_types', 1); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | /** |
@@ -134,30 +134,30 @@ discard block |
||
134 | 134 | */ |
135 | 135 | function give_setup_taxonomies() { |
136 | 136 | |
137 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
137 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
138 | 138 | |
139 | 139 | /** Categories */ |
140 | 140 | $category_labels = array( |
141 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
142 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
143 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
144 | - 'all_items' => __( 'All Categories', 'give' ), |
|
145 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
146 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
147 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
148 | - 'update_item' => __( 'Update Category', 'give' ), |
|
149 | - 'add_new_item' => __( 'Add New Category', 'give' ), |
|
150 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
151 | - 'menu_name' => __( 'Categories', 'give' ), |
|
141 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
142 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
143 | + 'search_items' => __('Search Categories', 'give'), |
|
144 | + 'all_items' => __('All Categories', 'give'), |
|
145 | + 'parent_item' => __('Parent Category', 'give'), |
|
146 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
147 | + 'edit_item' => __('Edit Category', 'give'), |
|
148 | + 'update_item' => __('Update Category', 'give'), |
|
149 | + 'add_new_item' => __('Add New Category', 'give'), |
|
150 | + 'new_item_name' => __('New Category Name', 'give'), |
|
151 | + 'menu_name' => __('Categories', 'give'), |
|
152 | 152 | ); |
153 | 153 | |
154 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
154 | + $category_args = apply_filters('give_forms_category_args', array( |
|
155 | 155 | 'hierarchical' => true, |
156 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
156 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
157 | 157 | 'show_ui' => true, |
158 | 158 | 'query_var' => 'give_forms_category', |
159 | 159 | 'rewrite' => array( |
160 | - 'slug' => $slug . '/category', |
|
160 | + 'slug' => $slug.'/category', |
|
161 | 161 | 'with_front' => false, |
162 | 162 | 'hierarchical' => true, |
163 | 163 | ), |
@@ -171,33 +171,33 @@ discard block |
||
171 | 171 | ); |
172 | 172 | |
173 | 173 | // Does the user want categories? |
174 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
175 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
176 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
174 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
175 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
176 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** Tags */ |
180 | 180 | $tag_labels = array( |
181 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
182 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
183 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
184 | - 'all_items' => __( 'All Tags', 'give' ), |
|
185 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
186 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
187 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
188 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
189 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
190 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
191 | - 'menu_name' => __( 'Tags', 'give' ), |
|
192 | - 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
|
181 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
182 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
183 | + 'search_items' => __('Search Tags', 'give'), |
|
184 | + 'all_items' => __('All Tags', 'give'), |
|
185 | + 'parent_item' => __('Parent Tag', 'give'), |
|
186 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
187 | + 'edit_item' => __('Edit Tag', 'give'), |
|
188 | + 'update_item' => __('Update Tag', 'give'), |
|
189 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
190 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
191 | + 'menu_name' => __('Tags', 'give'), |
|
192 | + 'choose_from_most_used' => __('Choose from most used tags.', 'give'), |
|
193 | 193 | ); |
194 | 194 | |
195 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
195 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
196 | 196 | 'hierarchical' => false, |
197 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
197 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
198 | 198 | 'show_ui' => true, |
199 | 199 | 'query_var' => 'give_forms_tag', |
200 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
200 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
201 | 201 | 'capabilities' => array( |
202 | 202 | 'manage_terms' => 'manage_give_form_terms', |
203 | 203 | 'edit_terms' => 'edit_give_form_terms', |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | ) |
208 | 208 | ); |
209 | 209 | |
210 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
211 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
212 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
210 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
211 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
212 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
217 | +add_action('init', 'give_setup_taxonomies', 0); |
|
218 | 218 | |
219 | 219 | |
220 | 220 | /** |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | */ |
226 | 226 | function give_get_default_form_labels() { |
227 | 227 | $defaults = array( |
228 | - 'singular' => __( 'Form', 'give' ), |
|
229 | - 'plural' => __( 'Forms', 'give' ), |
|
228 | + 'singular' => __('Form', 'give'), |
|
229 | + 'plural' => __('Forms', 'give'), |
|
230 | 230 | ); |
231 | 231 | |
232 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
232 | + return apply_filters('give_default_form_name', $defaults); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return string $defaults['singular'] Singular label |
243 | 243 | */ |
244 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
244 | +function give_get_forms_label_singular($lowercase = false) { |
|
245 | 245 | $defaults = give_get_default_form_labels(); |
246 | 246 | |
247 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
247 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * @since 1.0 |
254 | 254 | * @return string $defaults['plural'] Plural label |
255 | 255 | */ |
256 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
256 | +function give_get_forms_label_plural($lowercase = false) { |
|
257 | 257 | $defaults = give_get_default_form_labels(); |
258 | 258 | |
259 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
259 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return string $title New placeholder text |
270 | 270 | */ |
271 | -function give_change_default_title( $title ) { |
|
271 | +function give_change_default_title($title) { |
|
272 | 272 | // If a frontend plugin uses this filter (check extensions before changing this function) |
273 | - if ( ! is_admin() ) { |
|
274 | - $title = __( 'Enter form title here', 'give' ); |
|
273 | + if ( ! is_admin()) { |
|
274 | + $title = __('Enter form title here', 'give'); |
|
275 | 275 | |
276 | 276 | return $title; |
277 | 277 | } |
278 | 278 | |
279 | 279 | $screen = get_current_screen(); |
280 | 280 | |
281 | - if ( 'give_forms' == $screen->post_type ) { |
|
282 | - $title = __( 'Enter form title here', 'give' ); |
|
281 | + if ('give_forms' == $screen->post_type) { |
|
282 | + $title = __('Enter form title here', 'give'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return $title; |
286 | 286 | } |
287 | 287 | |
288 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
288 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Registers Custom Post Statuses which are used by the Payments |
@@ -295,67 +295,67 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function give_register_post_type_statuses() { |
297 | 297 | // Payment Statuses |
298 | - register_post_status( 'refunded', array( |
|
299 | - 'label' => __( 'Refunded', 'give' ), |
|
298 | + register_post_status('refunded', array( |
|
299 | + 'label' => __('Refunded', 'give'), |
|
300 | 300 | 'public' => true, |
301 | 301 | 'exclude_from_search' => false, |
302 | 302 | 'show_in_admin_all_list' => true, |
303 | 303 | 'show_in_admin_status_list' => true, |
304 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
305 | - ) ); |
|
306 | - register_post_status( 'failed', array( |
|
307 | - 'label' => __( 'Failed', 'give' ), |
|
304 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
305 | + )); |
|
306 | + register_post_status('failed', array( |
|
307 | + 'label' => __('Failed', 'give'), |
|
308 | 308 | 'public' => true, |
309 | 309 | 'exclude_from_search' => false, |
310 | 310 | 'show_in_admin_all_list' => true, |
311 | 311 | 'show_in_admin_status_list' => true, |
312 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
313 | - ) ); |
|
314 | - register_post_status( 'revoked', array( |
|
315 | - 'label' => __( 'Revoked', 'give' ), |
|
312 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
313 | + )); |
|
314 | + register_post_status('revoked', array( |
|
315 | + 'label' => __('Revoked', 'give'), |
|
316 | 316 | 'public' => true, |
317 | 317 | 'exclude_from_search' => false, |
318 | 318 | 'show_in_admin_all_list' => true, |
319 | 319 | 'show_in_admin_status_list' => true, |
320 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
321 | - ) ); |
|
322 | - register_post_status( 'cancelled', array( |
|
323 | - 'label' => __( 'Cancelled', 'give' ), |
|
320 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
321 | + )); |
|
322 | + register_post_status('cancelled', array( |
|
323 | + 'label' => __('Cancelled', 'give'), |
|
324 | 324 | 'public' => true, |
325 | 325 | 'exclude_from_search' => false, |
326 | 326 | 'show_in_admin_all_list' => true, |
327 | 327 | 'show_in_admin_status_list' => true, |
328 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
329 | - ) ); |
|
330 | - register_post_status( 'abandoned', array( |
|
331 | - 'label' => __( 'Abandoned', 'give' ), |
|
328 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
329 | + )); |
|
330 | + register_post_status('abandoned', array( |
|
331 | + 'label' => __('Abandoned', 'give'), |
|
332 | 332 | 'public' => true, |
333 | 333 | 'exclude_from_search' => false, |
334 | 334 | 'show_in_admin_all_list' => true, |
335 | 335 | 'show_in_admin_status_list' => true, |
336 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
337 | - ) ); |
|
338 | - register_post_status( 'processing', array( |
|
339 | - 'label' => _x( 'Processing', 'Processing payment status', 'give' ), |
|
336 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
337 | + )); |
|
338 | + register_post_status('processing', array( |
|
339 | + 'label' => _x('Processing', 'Processing payment status', 'give'), |
|
340 | 340 | 'public' => true, |
341 | 341 | 'exclude_from_search' => false, |
342 | 342 | 'show_in_admin_all_list' => true, |
343 | 343 | 'show_in_admin_status_list' => true, |
344 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ) |
|
345 | - ) ); |
|
344 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give') |
|
345 | + )); |
|
346 | 346 | |
347 | - register_post_status( 'preapproval', array( |
|
348 | - 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ), |
|
347 | + register_post_status('preapproval', array( |
|
348 | + 'label' => _x('Preapproval', 'Preapproval payment status', 'give'), |
|
349 | 349 | 'public' => true, |
350 | 350 | 'exclude_from_search' => false, |
351 | 351 | 'show_in_admin_all_list' => true, |
352 | 352 | 'show_in_admin_status_list' => true, |
353 | - 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ), |
|
354 | - ) ); |
|
353 | + 'label_count' => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'), |
|
354 | + )); |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
358 | +add_action('init', 'give_register_post_type_statuses'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Updated Messages |
@@ -368,27 +368,27 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return array $messages New post updated messages |
370 | 370 | */ |
371 | -function give_updated_messages( $messages ) { |
|
371 | +function give_updated_messages($messages) { |
|
372 | 372 | global $post, $post_ID; |
373 | 373 | |
374 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
374 | + if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
375 | 375 | |
376 | 376 | $messages['give_forms'] = array( |
377 | - 1 => __( 'Form updated.', 'give' ), |
|
378 | - 4 => __( 'Form updated.', 'give' ), |
|
379 | - 6 => __( 'Form published.', 'give' ), |
|
380 | - 7 => __( 'Form saved.', 'give' ), |
|
381 | - 8 => __( 'Form submitted.', 'give' ), |
|
377 | + 1 => __('Form updated.', 'give'), |
|
378 | + 4 => __('Form updated.', 'give'), |
|
379 | + 6 => __('Form published.', 'give'), |
|
380 | + 7 => __('Form saved.', 'give'), |
|
381 | + 8 => __('Form submitted.', 'give'), |
|
382 | 382 | ); |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | 386 | $messages['give_forms'] = array( |
387 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
388 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
389 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
390 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
391 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
387 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
388 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
389 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
390 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
391 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | } |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | return $messages; |
397 | 397 | } |
398 | 398 | |
399 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
399 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Ensure post thumbnail support is turned on |
403 | 403 | */ |
404 | 404 | function give_add_thumbnail_support() { |
405 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
405 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
410 | - add_theme_support( 'post-thumbnails' ); |
|
409 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
410 | + add_theme_support('post-thumbnails'); |
|
411 | 411 | } |
412 | 412 | |
413 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
413 | + add_post_type_support('give_forms', 'thumbnail'); |
|
414 | 414 | } |
415 | 415 | |
416 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
416 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Give Sidebars |
@@ -424,21 +424,21 @@ discard block |
||
424 | 424 | |
425 | 425 | // Single Give Forms (disabled if single turned off in settings) |
426 | 426 | if ( |
427 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
428 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
427 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
428 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
429 | 429 | ) { |
430 | 430 | |
431 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
432 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
431 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
432 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
433 | 433 | 'id' => 'give-forms-sidebar', |
434 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
434 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
435 | 435 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
436 | 436 | 'after_widget' => '</div>', |
437 | 437 | 'before_title' => '<h3 class="widgettitle widget-title">', |
438 | 438 | 'after_title' => '</h3>', |
439 | - ) ) ); |
|
439 | + ))); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
444 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,41 +64,41 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - $form_title = get_the_title( $item[ $column_name ] ); |
|
74 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title; |
|
75 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>'; |
|
73 | + $form_title = get_the_title($item[$column_name]); |
|
74 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title; |
|
75 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>'; |
|
76 | 76 | |
77 | 77 | case 'donor_id' : |
78 | 78 | return sprintf( |
79 | 79 | '<a href="%s">%s</a>', |
80 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['donor_id'] ) ), |
|
80 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['donor_id'])), |
|
81 | 81 | $item['donor_name'] |
82 | 82 | ); |
83 | 83 | |
84 | 84 | case 'amount' : |
85 | - return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false ) ) ); |
|
85 | + return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false))); |
|
86 | 86 | |
87 | 87 | case 'status' : |
88 | 88 | |
89 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
89 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
90 | 90 | |
91 | - if ( $payment->mode == 'test' ) { |
|
92 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>'; |
|
91 | + if ($payment->mode == 'test') { |
|
92 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
96 | 96 | |
97 | 97 | case 'payment_id' : |
98 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
98 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
99 | 99 | |
100 | 100 | default: |
101 | - return $item[ $column_name ]; |
|
101 | + return $item[$column_name]; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_columns() { |
113 | 113 | $columns = array( |
114 | - 'ID' => __( 'Log ID', 'give' ), |
|
115 | - 'donor_id' => __( 'Donor', 'give' ), |
|
116 | - 'form' => __( 'Form', 'give' ), |
|
117 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
118 | - 'status' => __( 'Status', 'give' ), |
|
119 | - 'payment_id' => __( 'Donation ID', 'give' ), |
|
120 | - 'date' => __( 'Date', 'give' ), |
|
114 | + 'ID' => __('Log ID', 'give'), |
|
115 | + 'donor_id' => __('Donor', 'give'), |
|
116 | + 'form' => __('Form', 'give'), |
|
117 | + 'amount' => __('Donation Amount', 'give'), |
|
118 | + 'status' => __('Status', 'give'), |
|
119 | + 'payment_id' => __('Donation ID', 'give'), |
|
120 | + 'date' => __('Date', 'give'), |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | return $columns; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return int Current page number |
132 | 132 | */ |
133 | 133 | public function get_paged() { |
134 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
134 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return mixed int If User ID, string If Email/Login |
143 | 143 | */ |
144 | 144 | public function get_filtered_user() { |
145 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
145 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return int Download ID |
154 | 154 | */ |
155 | 155 | public function get_filtered_give_form() { |
156 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
156 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string|bool string If search is present, false otherwise |
165 | 165 | */ |
166 | 166 | public function get_search() { |
167 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
167 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -180,20 +180,20 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $which |
182 | 182 | */ |
183 | - protected function display_tablenav( $which ) { |
|
183 | + protected function display_tablenav($which) { |
|
184 | 184 | |
185 | - if ( 'top' === $which ) { |
|
186 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
185 | + if ('top' === $which) { |
|
186 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
187 | 187 | } |
188 | 188 | ?> |
189 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
189 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
190 | 190 | |
191 | 191 | <div class="alignleft actions bulkactions"> |
192 | - <?php $this->bulk_actions( $which ); ?> |
|
192 | + <?php $this->bulk_actions($which); ?> |
|
193 | 193 | </div> |
194 | 194 | <?php |
195 | - $this->extra_tablenav( $which ); |
|
196 | - $this->pagination( $which ); |
|
195 | + $this->extra_tablenav($which); |
|
196 | + $this->pagination($which); |
|
197 | 197 | ?> |
198 | 198 | |
199 | 199 | <br class="clear"/> |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $meta_query = array(); |
219 | 219 | |
220 | - if ( $user ) { |
|
220 | + if ($user) { |
|
221 | 221 | // Show only logs from a specific user. |
222 | 222 | $meta_query[] = array( |
223 | 223 | 'key' => '_give_log_user_id', |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | $search = $this->get_search(); |
229 | - if ( $search ) { |
|
230 | - if ( is_email( $search ) ) { |
|
229 | + if ($search) { |
|
230 | + if (is_email($search)) { |
|
231 | 231 | // This is an email search. We use this to ensure it works for guest users and logged-in users. |
232 | 232 | $key = '_give_log_user_info'; |
233 | 233 | $compare = 'LIKE'; |
@@ -236,32 +236,32 @@ discard block |
||
236 | 236 | $key = '_give_log_user_id'; |
237 | 237 | $compare = 'LIKE'; |
238 | 238 | |
239 | - if ( ! is_numeric( $search ) ) { |
|
239 | + if ( ! is_numeric($search)) { |
|
240 | 240 | // Searching for user by username |
241 | - $user = get_user_by( 'login', $search ); |
|
241 | + $user = get_user_by('login', $search); |
|
242 | 242 | |
243 | - if ( $user ) { |
|
243 | + if ($user) { |
|
244 | 244 | // Found one, set meta value to user's ID. |
245 | 245 | $search = $user->ID; |
246 | 246 | } else { |
247 | 247 | // No user found so let's do a real search query. |
248 | - $users = new WP_User_Query( array( |
|
248 | + $users = new WP_User_Query(array( |
|
249 | 249 | 'search' => $search, |
250 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
250 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
251 | 251 | 'number' => 1, |
252 | 252 | 'fields' => 'ids', |
253 | - ) ); |
|
253 | + )); |
|
254 | 254 | |
255 | 255 | $found_user = $users->get_results(); |
256 | 256 | |
257 | - if ( $found_user ) { |
|
257 | + if ($found_user) { |
|
258 | 258 | $search = $found_user[0]; |
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( ! $this->file_search ) { |
|
264 | + if ( ! $this->file_search) { |
|
265 | 265 | // Meta query only works for non file name search. |
266 | 266 | $meta_query[] = array( |
267 | 267 | 'key' => $key, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @since 1.0 |
283 | 283 | * @return void |
284 | 284 | */ |
285 | - function bulk_actions( $which = '' ) { |
|
285 | + function bulk_actions($which = '') { |
|
286 | 286 | give_log_views(); |
287 | 287 | } |
288 | 288 | |
@@ -294,24 +294,24 @@ discard block |
||
294 | 294 | * @return void |
295 | 295 | */ |
296 | 296 | public function give_forms_filter() { |
297 | - $give_forms = get_posts( array( |
|
297 | + $give_forms = get_posts(array( |
|
298 | 298 | 'post_type' => 'give_forms', |
299 | 299 | 'post_status' => 'any', |
300 | - 'posts_per_page' => - 1, |
|
300 | + 'posts_per_page' => -1, |
|
301 | 301 | 'orderby' => 'title', |
302 | 302 | 'order' => 'ASC', |
303 | 303 | 'fields' => 'ids', |
304 | 304 | 'update_post_meta_cache' => false, |
305 | 305 | 'update_post_term_cache' => false, |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | |
308 | - if ( $give_forms ) { |
|
308 | + if ($give_forms) { |
|
309 | 309 | echo '<select name="form" id="give-log-form-filter">'; |
310 | - echo '<option value="0">' . __( 'All', 'give' ) . '</option>'; |
|
311 | - foreach ( $give_forms as $form ) { |
|
312 | - $form_title = get_the_title( $form ); |
|
313 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title; |
|
314 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>'; |
|
310 | + echo '<option value="0">'.__('All', 'give').'</option>'; |
|
311 | + foreach ($give_forms as $form) { |
|
312 | + $form_title = get_the_title($form); |
|
313 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title; |
|
314 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>'; |
|
315 | 315 | } |
316 | 316 | echo '</select>'; |
317 | 317 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | $logs_data = array(); |
333 | 333 | $paged = $this->get_paged(); |
334 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
334 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
335 | 335 | $user = $this->get_filtered_user(); |
336 | 336 | |
337 | 337 | $log_query = array( |
@@ -342,37 +342,37 @@ discard block |
||
342 | 342 | 'posts_per_page' => $this->per_page, |
343 | 343 | ); |
344 | 344 | |
345 | - $cache_key = Give_Cache::get_key( 'get_logs', $log_query ); |
|
345 | + $cache_key = Give_Cache::get_key('get_logs', $log_query); |
|
346 | 346 | |
347 | 347 | // Return result from cache if exist. |
348 | - if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) { |
|
349 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
348 | + if ( ! ($logs_data = Give_Cache::get($cache_key))) { |
|
349 | + $logs = $give_logs->get_connected_logs($log_query); |
|
350 | 350 | |
351 | - if ( $logs ) { |
|
352 | - foreach ( $logs as $log ) { |
|
353 | - $payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
351 | + if ($logs) { |
|
352 | + foreach ($logs as $log) { |
|
353 | + $payment_id = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
354 | 354 | |
355 | 355 | // Make sure this payment hasn't been deleted. |
356 | - if ( get_post( $payment_id ) ) : |
|
357 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
358 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
356 | + if (get_post($payment_id)) : |
|
357 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
358 | + $payment_amount = give_get_payment_amount($payment_id); |
|
359 | 359 | |
360 | 360 | $logs_data[] = array( |
361 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
361 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
362 | 362 | 'payment_id' => $payment_id, |
363 | 363 | 'form' => $log->post_parent, |
364 | 364 | 'amount' => $payment_amount, |
365 | - 'donor_id' => give_get_payment_donor_id( $payment_id ), |
|
366 | - 'donor_name' => trim( "{$user_info['first_name']} {$user_info['last_name']}" ), |
|
367 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
365 | + 'donor_id' => give_get_payment_donor_id($payment_id), |
|
366 | + 'donor_name' => trim("{$user_info['first_name']} {$user_info['last_name']}"), |
|
367 | + 'date' => get_post_field('post_date', $payment_id), |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | endif; |
371 | 371 | } |
372 | 372 | |
373 | 373 | // Cache results. |
374 | - if ( ! empty( $logs_data ) ) { |
|
375 | - Give_Cache::set( $cache_key, $logs_data ); |
|
374 | + if ( ! empty($logs_data)) { |
|
375 | + Give_Cache::set($cache_key, $logs_data); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | $columns = $this->get_columns(); |
401 | 401 | $hidden = array(); |
402 | 402 | $sortable = $this->get_sortable_columns(); |
403 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
403 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
404 | 404 | $current_page = $this->get_pagenum(); |
405 | 405 | $this->items = $this->get_logs(); |
406 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
406 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
407 | 407 | |
408 | - $this->set_pagination_args( array( |
|
408 | + $this->set_pagination_args(array( |
|
409 | 409 | 'total_items' => $total_items, |
410 | 410 | 'per_page' => $this->per_page, |
411 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
411 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
412 | 412 | ) |
413 | 413 | ); |
414 | 414 | } |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | global $status, $page; |
63 | 63 | |
64 | 64 | // Set parent defaults |
65 | - parent::__construct( array( |
|
66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
68 | - 'ajax' => false,// Does this table support ajax? |
|
69 | - ) ); |
|
65 | + parent::__construct(array( |
|
66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
68 | + 'ajax' => false, // Does this table support ajax? |
|
69 | + )); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return false |
85 | 85 | */ |
86 | - public function search_box( $text, $input_id ) { |
|
86 | + public function search_box($text, $input_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function give_search_box( $text, $input_id ) { |
|
102 | - $input_id = $input_id . '-search-input'; |
|
101 | + public function give_search_box($text, $input_id) { |
|
102 | + $input_id = $input_id.'-search-input'; |
|
103 | 103 | |
104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
106 | 106 | } |
107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
107 | + if ( ! empty($_REQUEST['order'])) { |
|
108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | <p class="search-box donor-search" role="search"> |
112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
115 | 115 | </p> |
116 | 116 | <?php |
117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $which |
126 | 126 | */ |
127 | - protected function display_tablenav( $which ) { |
|
127 | + protected function display_tablenav($which) { |
|
128 | 128 | |
129 | - if ( 'top' === $which ) { |
|
130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
129 | + if ('top' === $which) { |
|
130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
131 | 131 | } |
132 | 132 | ?> |
133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
134 | 134 | |
135 | - <?php if ( 'top' === $which ) { ?> |
|
135 | + <?php if ('top' === $which) { ?> |
|
136 | 136 | <h3 class="alignleft reports-earnings-title"> |
137 | - <span><?php esc_html_e( 'Donors Report', 'give' ); ?></span> |
|
137 | + <span><?php esc_html_e('Donors Report', 'give'); ?></span> |
|
138 | 138 | </h3> |
139 | 139 | <?php } ?> |
140 | 140 | |
141 | 141 | <div class="alignright tablenav-right"> |
142 | 142 | <div class="actions bulkactions"> |
143 | 143 | <?php |
144 | - if ( 'top' === $which ) { |
|
145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
144 | + if ('top' === $which) { |
|
145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
146 | 146 | } |
147 | 147 | |
148 | - $this->bulk_actions( $which ); ?> |
|
148 | + $this->bulk_actions($which); ?> |
|
149 | 149 | |
150 | 150 | </div> |
151 | 151 | <?php |
152 | - $this->extra_tablenav( $which ); |
|
153 | - $this->pagination( $which ); |
|
152 | + $this->extra_tablenav($which); |
|
153 | + $this->pagination($which); |
|
154 | 154 | ?> |
155 | 155 | </div> |
156 | 156 | |
@@ -172,35 +172,35 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string Column Name |
174 | 174 | */ |
175 | - public function column_default( $item, $column_name ) { |
|
175 | + public function column_default($item, $column_name) { |
|
176 | 176 | |
177 | - switch ( $column_name ) { |
|
177 | + switch ($column_name) { |
|
178 | 178 | |
179 | 179 | case 'name' : |
180 | - $name = '#' . $item['id'] . ' '; |
|
181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
180 | + $name = '#'.$item['id'].' '; |
|
181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | 187 | $value = sprintf( |
188 | 188 | '<a href="%s">%s</a>', |
189 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['id'] ) ), |
|
190 | - esc_html( $item['num_donations'] ) |
|
189 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['id'])), |
|
190 | + esc_html($item['num_donations']) |
|
191 | 191 | ); |
192 | 192 | break; |
193 | 193 | |
194 | 194 | case 'amount_spent' : |
195 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
195 | + $value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | default: |
199 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
199 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
200 | 200 | break; |
201 | 201 | } |
202 | 202 | |
203 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
203 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function get_columns() { |
214 | 214 | $columns = array( |
215 | - 'name' => __( 'Name', 'give' ), |
|
216 | - 'email' => __( 'Email', 'give' ), |
|
217 | - 'num_donations' => __( 'Donations', 'give' ), |
|
218 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
215 | + 'name' => __('Name', 'give'), |
|
216 | + 'email' => __('Email', 'give'), |
|
217 | + 'num_donations' => __('Donations', 'give'), |
|
218 | + 'amount_spent' => __('Total Donated', 'give'), |
|
219 | 219 | ); |
220 | 220 | |
221 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
221 | + return apply_filters('give_report_donor_columns', $columns); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function get_sortable_columns() { |
233 | 233 | return array( |
234 | - 'id' => array( 'id', true ), |
|
235 | - 'name' => array( 'name', true ), |
|
236 | - 'num_donations' => array( 'purchase_count', false ), |
|
237 | - 'amount_spent' => array( 'purchase_value', false ), |
|
234 | + 'id' => array('id', true), |
|
235 | + 'name' => array('name', true), |
|
236 | + 'num_donations' => array('purchase_count', false), |
|
237 | + 'amount_spent' => array('purchase_value', false), |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @since 1.0 |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function bulk_actions( $which = '' ) { |
|
248 | + public function bulk_actions($which = '') { |
|
249 | 249 | |
250 | 250 | } |
251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return int Current page number |
258 | 258 | */ |
259 | 259 | public function get_paged() { |
260 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
260 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return mixed string If search is present, false otherwise |
269 | 269 | */ |
270 | 270 | public function get_search() { |
271 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
271 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | |
288 | 288 | // Get donor query. |
289 | 289 | $args = $this->get_donor_query(); |
290 | - $donors = Give()->donors->get_donors( $args ); |
|
290 | + $donors = Give()->donors->get_donors($args); |
|
291 | 291 | |
292 | - if ( $donors ) { |
|
292 | + if ($donors) { |
|
293 | 293 | |
294 | - $this->count = count( $donors ); |
|
294 | + $this->count = count($donors); |
|
295 | 295 | |
296 | - foreach ( $donors as $donor ) { |
|
296 | + foreach ($donors as $donor) { |
|
297 | 297 | |
298 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
298 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
299 | 299 | |
300 | 300 | $data[] = array( |
301 | 301 | 'id' => $donor->id, |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $_donor_query['number'] = -1; |
325 | 325 | $_donor_query['offset'] = 0; |
326 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
326 | + $donors = Give()->donors->get_donors($_donor_query); |
|
327 | 327 | |
328 | - return count( $donors ); |
|
328 | + return count($donors); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function get_donor_query() { |
339 | 339 | $paged = $this->get_paged(); |
340 | - $offset = $this->per_page * ( $paged - 1 ); |
|
340 | + $offset = $this->per_page * ($paged - 1); |
|
341 | 341 | $search = $this->get_search(); |
342 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
343 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
342 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
343 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
344 | 344 | |
345 | 345 | $args = array( |
346 | 346 | 'number' => $this->per_page, |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | 'orderby' => $orderby, |
350 | 350 | ); |
351 | 351 | |
352 | - if( $search ) { |
|
353 | - if ( is_email( $search ) ) { |
|
352 | + if ($search) { |
|
353 | + if (is_email($search)) { |
|
354 | 354 | $args['email'] = $search; |
355 | - } elseif ( is_numeric( $search ) ) { |
|
355 | + } elseif (is_numeric($search)) { |
|
356 | 356 | $args['id'] = $search; |
357 | 357 | } else { |
358 | 358 | $args['name'] = $search; |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | $hidden = array(); // No hidden columns |
380 | 380 | $sortable = $this->get_sortable_columns(); |
381 | 381 | |
382 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
382 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
383 | 383 | |
384 | 384 | $this->items = $this->reports_data(); |
385 | 385 | |
386 | 386 | $this->total = $this->get_donor_count(); |
387 | 387 | |
388 | - $this->set_pagination_args( array( |
|
388 | + $this->set_pagination_args(array( |
|
389 | 389 | 'total_items' => $this->total, |
390 | 390 | 'per_page' => $this->per_page, |
391 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
392 | - ) ); |
|
391 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_donors_page() { |
26 | 26 | $default_views = give_donor_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_donor_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_donor_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_donors_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_donor_views', $views ); |
|
45 | + return apply_filters('give_donor_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
59 | + return apply_filters('give_donor_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_donors_list() { |
70 | - include dirname( __FILE__ ) . '/class-donor-table.php'; |
|
70 | + include dirname(__FILE__).'/class-donor-table.php'; |
|
71 | 71 | |
72 | 72 | $donors_table = new Give_Donor_List_Table(); |
73 | 73 | $donors_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $donors_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $donors_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $donors_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_donor_view( $view, $callbacks ) { |
|
116 | +function give_render_donor_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
120 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($donor_view_role)) { |
|
123 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $donor_id = (int) $_GET['id']; |
133 | - $donor = new Give_Donor( $donor_id ); |
|
133 | + $donor = new Give_Donor($donor_id); |
|
134 | 134 | |
135 | - if ( empty( $donor->id ) ) { |
|
136 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($donor->id)) { |
|
136 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
147 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $donor && $render ) : ?> |
|
153 | + <?php if ($donor && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $donor_tabs as $key => $tab ) : |
|
157 | + foreach ($donor_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
161 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-donor-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
172 | + <?php $callbacks[$view]($donor) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_donor_view( $donor ) { |
|
192 | +function give_donor_view($donor) { |
|
193 | 193 | |
194 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
194 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $donor The donor object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $donor ); |
|
203 | + do_action('give_donor_card_top', $donor); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
207 | 207 | |
208 | - <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
208 | + <form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="donor-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="donor-avatar"> |
215 | - <?php echo get_avatar( $donor->email ); ?> |
|
215 | + <?php echo get_avatar($donor->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="donor-name-wrap" class="left"> |
219 | 219 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
220 | - <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="donor-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
228 | - <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
228 | + <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User:', 'give'); ?></label></th> |
|
239 | 239 | <td> |
240 | 240 | <span class="donor-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -252,37 +252,37 @@ discard block |
||
252 | 252 | 'data' => $data_atts, |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $user_id ) ) { |
|
256 | - $userdata = get_userdata( $user_id ); |
|
255 | + if ( ! empty($user_id)) { |
|
256 | + $userdata = get_userdata($user_id); |
|
257 | 257 | $user_args['selected'] = $user_id; |
258 | 258 | } |
259 | 259 | |
260 | - echo Give()->html->ajax_user_search( $user_args ); |
|
260 | + echo Give()->html->ajax_user_search($user_args); |
|
261 | 261 | ?> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="donor-user-id info-item editable"> |
265 | - <?php if ( ! empty( $userdata ) ) { ?> |
|
266 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
265 | + <?php if ( ! empty($userdata)) { ?> |
|
266 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this donor record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($donor->user_id) && $donor->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="donor-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($donor->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '', |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="donor-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="donor-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province / County', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province / County', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="donor-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-donor" /> |
363 | - <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $donor The donor object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $donor ); |
|
379 | + do_action('give_donor_before_stats', $donor); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | // Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($donor->purchase_value, array('sanitize' => false))); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $donor The donor object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $donor ); |
|
408 | + do_action('give_donor_stats_list', $donor); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $donor The donor object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -431,46 +431,46 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $donor The donor object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $donor ); |
|
434 | + do_action('give_donor_before_tables', $donor); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($donor->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
463 | - 'email' => rawurlencode( $email ), |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
463 | + 'email' => rawurlencode($email), |
|
464 | 464 | 'give_action' => 'set_donor_primary_email', |
465 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
466 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
467 | - 'email' => rawurlencode( $email ), |
|
465 | + ), $base_url), 'give-set-donor-primary-email'); |
|
466 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
467 | + 'email' => rawurlencode($email), |
|
468 | 468 | 'give_action' => 'remove_donor_email', |
469 | - ), $base_url ), 'give-remove-donor-email' ); |
|
469 | + ), $base_url), 'give-remove-donor-email'); |
|
470 | 470 | ?> |
471 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
471 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
472 | 472 | | |
473 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
473 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
474 | 474 | <?php endif; ?> |
475 | 475 | </td> |
476 | 476 | </tr> |
@@ -480,59 +480,59 @@ discard block |
||
480 | 480 | <td colspan="2" class="add-donor-email-td"> |
481 | 481 | <div class="add-donor-email-wrapper"> |
482 | 482 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
483 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
484 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
485 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
486 | - <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
483 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
484 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
485 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
486 | + <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
487 | 487 | <span class="spinner"></span> |
488 | 488 | </div> |
489 | 489 | <div class="notice-wrap"></div> |
490 | 490 | </td> |
491 | 491 | </tr> |
492 | 492 | <?php } else { ?> |
493 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr> |
|
493 | + <tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr> |
|
494 | 494 | <?php }// End if(). |
495 | 495 | ?> |
496 | 496 | </tbody> |
497 | 497 | </table> |
498 | 498 | |
499 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
499 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
500 | 500 | <?php |
501 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
502 | - $payments = give_get_payments( array( |
|
501 | + $payment_ids = explode(',', $donor->payment_ids); |
|
502 | + $payments = give_get_payments(array( |
|
503 | 503 | 'post__in' => $payment_ids, |
504 | - ) ); |
|
505 | - $payments = array_slice( $payments, 0, 10 ); |
|
504 | + )); |
|
505 | + $payments = array_slice($payments, 0, 10); |
|
506 | 506 | ?> |
507 | 507 | <table class="wp-list-table widefat striped payments"> |
508 | 508 | <thead> |
509 | 509 | <tr> |
510 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
511 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
512 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
513 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
514 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
510 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
511 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
512 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
513 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
514 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
515 | 515 | </tr> |
516 | 516 | </thead> |
517 | 517 | <tbody> |
518 | - <?php if ( ! empty( $payments ) ) { ?> |
|
519 | - <?php foreach ( $payments as $payment ) : ?> |
|
518 | + <?php if ( ! empty($payments)) { ?> |
|
519 | + <?php foreach ($payments as $payment) : ?> |
|
520 | 520 | <tr> |
521 | 521 | <td><?php echo $payment->ID; ?></td> |
522 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
523 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
524 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
522 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
523 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
524 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
525 | 525 | <td> |
526 | 526 | <?php |
527 | 527 | printf( |
528 | 528 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
529 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
529 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
530 | 530 | sprintf( |
531 | 531 | /* translators: %s: Donation ID */ |
532 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
532 | + esc_attr__('View Donation %s.', 'give'), |
|
533 | 533 | $payment->ID |
534 | 534 | ), |
535 | - esc_html__( 'View Donation', 'give' ) |
|
535 | + esc_html__('View Donation', 'give') |
|
536 | 536 | ); |
537 | 537 | ?> |
538 | 538 | |
@@ -547,47 +547,47 @@ discard block |
||
547 | 547 | * @param object $donor The donor object being displayed. |
548 | 548 | * @param object $payment The payment object being displayed. |
549 | 549 | */ |
550 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
550 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
551 | 551 | ?> |
552 | 552 | </td> |
553 | 553 | </tr> |
554 | 554 | <?php endforeach; ?> |
555 | 555 | <?php } else { ?> |
556 | 556 | <tr> |
557 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
557 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
558 | 558 | </tr> |
559 | 559 | <?php }// End if(). |
560 | 560 | ?> |
561 | 561 | </tbody> |
562 | 562 | </table> |
563 | 563 | |
564 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
564 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
565 | 565 | <?php |
566 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
566 | + $donations = give_get_users_completed_donations($donor->email); |
|
567 | 567 | ?> |
568 | 568 | <table class="wp-list-table widefat striped donations"> |
569 | 569 | <thead> |
570 | 570 | <tr> |
571 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
572 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
571 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
572 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
573 | 573 | </tr> |
574 | 574 | </thead> |
575 | 575 | <tbody> |
576 | - <?php if ( ! empty( $donations ) ) { ?> |
|
577 | - <?php foreach ( $donations as $donation ) : ?> |
|
576 | + <?php if ( ! empty($donations)) { ?> |
|
577 | + <?php foreach ($donations as $donation) : ?> |
|
578 | 578 | <tr> |
579 | 579 | <td><?php echo $donation->post_title; ?></td> |
580 | 580 | <td> |
581 | 581 | <?php |
582 | 582 | printf( |
583 | 583 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
584 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
584 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: form name */ |
587 | - esc_attr__( 'View Form %s.', 'give' ), |
|
587 | + esc_attr__('View Form %s.', 'give'), |
|
588 | 588 | $donation->post_title |
589 | 589 | ), |
590 | - esc_html__( 'View Form', 'give' ) |
|
590 | + esc_html__('View Form', 'give') |
|
591 | 591 | ); |
592 | 592 | ?> |
593 | 593 | </td> |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | <?php endforeach; ?> |
596 | 596 | <?php } else { ?> |
597 | 597 | <tr> |
598 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
598 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
599 | 599 | </tr> |
600 | 600 | <?php } ?> |
601 | 601 | </tbody> |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @param object $donor The donor object being displayed. |
611 | 611 | */ |
612 | - do_action( 'give_donor_after_tables', $donor ); |
|
612 | + do_action('give_donor_after_tables', $donor); |
|
613 | 613 | ?> |
614 | 614 | |
615 | 615 | </div> |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @param object $donor The donor object being displayed. |
624 | 624 | */ |
625 | - do_action( 'give_donor_card_bottom', $donor ); |
|
625 | + do_action('give_donor_card_bottom', $donor); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -635,30 +635,30 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return void |
637 | 637 | */ |
638 | -function give_donor_notes_view( $donor ) { |
|
638 | +function give_donor_notes_view($donor) { |
|
639 | 639 | |
640 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
641 | - $paged = absint( $paged ); |
|
640 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
641 | + $paged = absint($paged); |
|
642 | 642 | $note_count = $donor->get_notes_count(); |
643 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
644 | - $total_pages = ceil( $note_count / $per_page ); |
|
645 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
643 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
644 | + $total_pages = ceil($note_count / $per_page); |
|
645 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
646 | 646 | ?> |
647 | 647 | |
648 | 648 | <div id="donor-notes-wrapper"> |
649 | 649 | <div class="donor-notes-header"> |
650 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
650 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
651 | 651 | </div> |
652 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
652 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
653 | 653 | |
654 | - <?php if ( 1 == $paged ) : ?> |
|
654 | + <?php if (1 == $paged) : ?> |
|
655 | 655 | <div style="display: block; margin-bottom: 55px;"> |
656 | - <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
656 | + <form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
657 | 657 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
658 | 658 | <br /> |
659 | 659 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
660 | 660 | <input type="hidden" name="give_action" value="add-donor-note" /> |
661 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
661 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
662 | 662 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
663 | 663 | </form> |
664 | 664 | </div> |
@@ -673,26 +673,26 @@ discard block |
||
673 | 673 | 'show_all' => true, |
674 | 674 | ); |
675 | 675 | |
676 | - echo paginate_links( $pagination_args ); |
|
676 | + echo paginate_links($pagination_args); |
|
677 | 677 | ?> |
678 | 678 | |
679 | 679 | <div id="give-donor-notes" class="postbox"> |
680 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
681 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
680 | + <?php if (count($donor_notes) > 0) { ?> |
|
681 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
682 | 682 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
683 | 683 | <span class="note-content-wrap"> |
684 | - <?php echo stripslashes( $note ); ?> |
|
684 | + <?php echo stripslashes($note); ?> |
|
685 | 685 | </span> |
686 | 686 | </div> |
687 | 687 | <?php endforeach; ?> |
688 | 688 | <?php } else { ?> |
689 | 689 | <div class="give-no-donor-notes"> |
690 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
690 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
691 | 691 | </div> |
692 | 692 | <?php } ?> |
693 | 693 | </div> |
694 | 694 | |
695 | - <?php echo paginate_links( $pagination_args ); ?> |
|
695 | + <?php echo paginate_links($pagination_args); ?> |
|
696 | 696 | |
697 | 697 | </div> |
698 | 698 | |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return void |
710 | 710 | */ |
711 | -function give_donor_delete_view( $donor ) { |
|
711 | +function give_donor_delete_view($donor) { |
|
712 | 712 | |
713 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
713 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Fires in donor delete screen, above the content. |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param object $donor The donor object being displayed. |
721 | 721 | */ |
722 | - do_action( 'give_donor_delete_top', $donor ); |
|
722 | + do_action('give_donor_delete_top', $donor); |
|
723 | 723 | ?> |
724 | 724 | |
725 | 725 | <div class="info-wrapper donor-section"> |
726 | 726 | |
727 | - <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
727 | + <form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
728 | 728 | |
729 | 729 | <div class="donor-notes-header"> |
730 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
730 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
731 | 731 | </div> |
732 | 732 | |
733 | 733 | |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | <span class="delete-donor-options"> |
737 | 737 | <p> |
738 | - <?php echo Give()->html->checkbox( array( |
|
738 | + <?php echo Give()->html->checkbox(array( |
|
739 | 739 | 'name' => 'give-donor-delete-confirm', |
740 | - ) ); ?> |
|
741 | - <label for="give-donor-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
740 | + )); ?> |
|
741 | + <label for="give-donor-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
742 | 742 | </p> |
743 | 743 | |
744 | 744 | <p> |
745 | - <?php echo Give()->html->checkbox( array( |
|
745 | + <?php echo Give()->html->checkbox(array( |
|
746 | 746 | 'name' => 'give-donor-delete-records', |
747 | 747 | 'options' => array( |
748 | 748 | 'disabled' => true, |
749 | 749 | ), |
750 | - ) ); ?> |
|
751 | - <label for="give-donor-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
750 | + )); ?> |
|
751 | + <label for="give-donor-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
752 | 752 | </p> |
753 | 753 | |
754 | 754 | <?php |
@@ -761,16 +761,16 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @param object $donor The donor object being displayed. |
763 | 763 | */ |
764 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
764 | + do_action('give_donor_delete_inputs', $donor); |
|
765 | 765 | ?> |
766 | 766 | </span> |
767 | 767 | |
768 | 768 | <span id="donor-edit-actions"> |
769 | 769 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
770 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
770 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
771 | 771 | <input type="hidden" name="give_action" value="delete-donor" /> |
772 | - <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
773 | - <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
772 | + <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
773 | + <a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
774 | 774 | </span> |
775 | 775 | |
776 | 776 | </div> |
@@ -786,5 +786,5 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @param object $donor The donor object being displayed. |
788 | 788 | */ |
789 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
789 | + do_action('give_donor_delete_bottom', $donor); |
|
790 | 790 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load WP_List_Table if not loaded |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
67 | - 'ajax' => false,// Does this table support ajax?. |
|
68 | - ) ); |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | + 'ajax' => false, // Does this table support ajax?. |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( |
|
96 | + <?php submit_button($text, 'button', false, false, array( |
|
97 | 97 | 'ID' => 'search-submit', |
98 | - ) ); ?> |
|
98 | + )); ?> |
|
99 | 99 | </p> |
100 | 100 | <?php |
101 | 101 | } |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name. |
113 | 113 | */ |
114 | - public function column_default( $donor, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($donor, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | |
117 | 117 | case 'num_donations' : |
118 | 118 | $value = sprintf( |
119 | 119 | '<a href="%s">%s</a>', |
120 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
121 | - esc_html( $donor['num_donations'] ) |
|
120 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
121 | + esc_html($donor['num_donations']) |
|
122 | 122 | ); |
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'amount_spent' : |
126 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
126 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | case 'date_created' : |
130 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
130 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | default: |
134 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
134 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] ); |
|
138 | + return apply_filters("give_report_column_{$column_name}", $value, $donor['id']); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function column_name( $donor ) { |
|
150 | - $name = '#' . $donor['id'] . ' '; |
|
151 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
152 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
153 | - $actions = $this->get_row_actions( $donor ); |
|
149 | + public function column_name($donor) { |
|
150 | + $name = '#'.$donor['id'].' '; |
|
151 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
152 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
153 | + $actions = $this->get_row_actions($donor); |
|
154 | 154 | |
155 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
155 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function get_columns() { |
166 | 166 | $columns = array( |
167 | - 'name' => __( 'Name', 'give' ), |
|
168 | - 'email' => __( 'Email', 'give' ), |
|
169 | - 'num_donations' => __( 'Donations', 'give' ), |
|
170 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
171 | - 'date_created' => __( 'Date Created', 'give' ), |
|
167 | + 'name' => __('Name', 'give'), |
|
168 | + 'email' => __('Email', 'give'), |
|
169 | + 'num_donations' => __('Donations', 'give'), |
|
170 | + 'amount_spent' => __('Total Donated', 'give'), |
|
171 | + 'date_created' => __('Date Created', 'give'), |
|
172 | 172 | ); |
173 | 173 | |
174 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
174 | + return apply_filters('give_list_donors_columns', $columns); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | public function get_sortable_columns() { |
186 | 186 | |
187 | 187 | $columns = array( |
188 | - 'date_created' => array( 'date_created', true ), |
|
189 | - 'name' => array( 'name', true ), |
|
190 | - 'num_donations' => array( 'purchase_count', false ), |
|
191 | - 'amount_spent' => array( 'purchase_value', false ), |
|
188 | + 'date_created' => array('date_created', true), |
|
189 | + 'name' => array('name', true), |
|
190 | + 'num_donations' => array('purchase_count', false), |
|
191 | + 'amount_spent' => array('purchase_value', false), |
|
192 | 192 | ); |
193 | 193 | |
194 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
194 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -204,19 +204,19 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array An array of action links. |
206 | 206 | */ |
207 | - public function get_row_actions( $donor ) { |
|
207 | + public function get_row_actions($donor) { |
|
208 | 208 | |
209 | 209 | $actions = array( |
210 | 210 | |
211 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
211 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
212 | 212 | |
213 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
213 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
214 | 214 | |
215 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
215 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
216 | 216 | |
217 | 217 | ); |
218 | 218 | |
219 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
219 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @since 1.0 |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - public function bulk_actions( $which = '' ) { |
|
233 | + public function bulk_actions($which = '') { |
|
234 | 234 | // These aren't really bulk actions but this outputs the markup in the right place. |
235 | 235 | } |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return int Current page number. |
243 | 243 | */ |
244 | 244 | public function get_paged() { |
245 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
245 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return mixed string If search is present, false otherwise. |
254 | 254 | */ |
255 | 255 | public function get_search() { |
256 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
256 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | |
271 | 271 | // Get donor query. |
272 | 272 | $args = $this->get_donor_query(); |
273 | - $donors = Give()->donors->get_donors( $args ); |
|
273 | + $donors = Give()->donors->get_donors($args); |
|
274 | 274 | |
275 | - if ( $donors ) { |
|
275 | + if ($donors) { |
|
276 | 276 | |
277 | - foreach ( $donors as $donor ) { |
|
277 | + foreach ($donors as $donor) { |
|
278 | 278 | |
279 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
279 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
280 | 280 | |
281 | 281 | $data[] = array( |
282 | 282 | 'id' => $donor->id, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
293 | + return apply_filters('give_donors_column_query_data', $data); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | |
306 | 306 | $_donor_query['number'] = - 1; |
307 | 307 | $_donor_query['offset'] = 0; |
308 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
308 | + $donors = Give()->donors->get_donors($_donor_query); |
|
309 | 309 | |
310 | - return count( $donors ); |
|
310 | + return count($donors); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function get_donor_query() { |
321 | 321 | $paged = $this->get_paged(); |
322 | - $offset = $this->per_page * ( $paged - 1 ); |
|
322 | + $offset = $this->per_page * ($paged - 1); |
|
323 | 323 | $search = $this->get_search(); |
324 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
325 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
324 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
325 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
326 | 326 | |
327 | 327 | $args = array( |
328 | 328 | 'number' => $this->per_page, |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | 'orderby' => $orderby, |
332 | 332 | ); |
333 | 333 | |
334 | - if ( $search ) { |
|
335 | - if ( is_email( $search ) ) { |
|
334 | + if ($search) { |
|
335 | + if (is_email($search)) { |
|
336 | 336 | $args['email'] = $search; |
337 | - } elseif ( is_numeric( $search ) ) { |
|
337 | + } elseif (is_numeric($search)) { |
|
338 | 338 | $args['id'] = $search; |
339 | 339 | } else { |
340 | 340 | $args['name'] = $search; |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | $hidden = array(); // No hidden columns. |
358 | 358 | $sortable = $this->get_sortable_columns(); |
359 | 359 | |
360 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
360 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
361 | 361 | |
362 | 362 | $this->items = $this->donor_data(); |
363 | 363 | |
364 | 364 | $this->total = $this->get_donor_count(); |
365 | 365 | |
366 | - $this->set_pagination_args( array( |
|
366 | + $this->set_pagination_args(array( |
|
367 | 367 | 'total_items' => $this->total, |
368 | 368 | 'per_page' => $this->per_page, |
369 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
370 | - ) ); |
|
369 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
370 | + )); |
|
371 | 371 | } |
372 | 372 | } |
@@ -388,6 +388,9 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | + /** |
|
392 | + * @param boolean $value |
|
393 | + */ |
|
391 | 394 | static function selected( $option_value, $value ) { |
392 | 395 | $selected = ''; |
393 | 396 | if ( stristr( $value, $option_value ) ) { |
@@ -456,6 +459,9 @@ discard block |
||
456 | 459 | <?php |
457 | 460 | } |
458 | 461 | |
462 | + /** |
|
463 | + * @param integer $file_id |
|
464 | + */ |
|
459 | 465 | static function get_csv_total( $file_id ) { |
460 | 466 | $total = false; |
461 | 467 | if ( $file_id ) { |
@@ -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_Import' ) ) { |
|
16 | +if ( ! class_exists('Give_Settings_Import')) { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Import. |
@@ -56,37 +56,37 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __construct() { |
58 | 58 | $this->id = 'import'; |
59 | - $this->label = __( 'Import Donations', 'give' ); |
|
59 | + $this->label = __('Import Donations', 'give'); |
|
60 | 60 | |
61 | 61 | // Add Import tab in submenu. |
62 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
62 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
63 | 63 | // Will display html of the import donation. |
64 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_import_field' ), 10, 2 ); |
|
64 | + add_action('give_admin_field_tools_import', array($this, 'render_import_field'), 10, 2); |
|
65 | 65 | // Will call the function that genetrated the hook called 'give_admin_field_tools_import'. |
66 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
66 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
67 | 67 | // Do not use main form for this tab. |
68 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
69 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
70 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
68 | + if (give_get_current_setting_tab() === $this->id) { |
|
69 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
70 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
71 | 71 | } |
72 | 72 | // Run when form submit. |
73 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
74 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
73 | + add_action('give-tools_save_import', array($this, 'save')); |
|
74 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
75 | 75 | |
76 | 76 | |
77 | 77 | // Will add the progress of the import |
78 | - add_action( 'give_tools_import_form_before_start', array( 'Give_Settings_Import', 'progress' ), 10 ); |
|
78 | + add_action('give_tools_import_form_before_start', array('Give_Settings_Import', 'progress'), 10); |
|
79 | 79 | // Print the HTML. |
80 | - add_action( 'give_tools_import_form_start', array( 'Give_Settings_Import', 'html' ), 10 ); |
|
80 | + add_action('give_tools_import_form_start', array('Give_Settings_Import', 'html'), 10); |
|
81 | 81 | // Used to add submit button. |
82 | - add_action( 'give_tools_import_form_end', array( 'Give_Settings_Import', 'submit' ), 10 ); |
|
82 | + add_action('give_tools_import_form_end', array('Give_Settings_Import', 'submit'), 10); |
|
83 | 83 | // Print the html for CSV file upload. |
84 | - add_action( 'give_admin_field_media_csv', array( $this, 'render_media_csv' ), 10, 2 ); |
|
84 | + add_action('give_admin_field_media_csv', array($this, 'render_media_csv'), 10, 2); |
|
85 | 85 | } |
86 | 86 | |
87 | - static function update_notices( $messages ) { |
|
88 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
89 | - unset( $messages['give-setting-updated'] ); |
|
87 | + static function update_notices($messages) { |
|
88 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
89 | + unset($messages['give-setting-updated']); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $messages; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @since 1.8.13 |
99 | 99 | */ |
100 | 100 | static function submit() { |
101 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
101 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
102 | 102 | ?> |
103 | 103 | <input type="hidden" class="import-step" id="import-step" name="step" |
104 | 104 | value="<?php echo Give_Settings_Import::get_step(); ?>"/> |
@@ -114,33 +114,33 @@ discard block |
||
114 | 114 | $step = Give_Settings_Import::get_step(); |
115 | 115 | ?> |
116 | 116 | <section> |
117 | - <table class="widefat export-options-table give-table <?php echo 'step-' . $step; ?>" |
|
118 | - id="<?php echo 'step-' . $step; ?>"> |
|
117 | + <table class="widefat export-options-table give-table <?php echo 'step-'.$step; ?>" |
|
118 | + id="<?php echo 'step-'.$step; ?>"> |
|
119 | 119 | <tbody> |
120 | 120 | <?php |
121 | - if ( 1 === $step ) { |
|
121 | + if (1 === $step) { |
|
122 | 122 | // Get the html of CSV file upload. |
123 | 123 | Give_Settings_Import::render_media_csv(); |
124 | - } elseif ( 2 === $step ) { |
|
124 | + } elseif (2 === $step) { |
|
125 | 125 | Give_Settings_Import::render_dropdown(); |
126 | - } elseif ( 3 === $step ) { |
|
126 | + } elseif (3 === $step) { |
|
127 | 127 | // Drop down for importer files. |
128 | 128 | Give_Settings_Import::start_import(); |
129 | - } elseif ( 4 === $step ) { |
|
129 | + } elseif (4 === $step) { |
|
130 | 130 | // Successful or fail message. |
131 | 131 | Give_Settings_Import::import_success(); |
132 | 132 | } |
133 | 133 | |
134 | - if ( self::check_for_dropdown_or_import() == false ) { |
|
134 | + if (self::check_for_dropdown_or_import() == false) { |
|
135 | 135 | $step = Give_Settings_Import::get_step(); |
136 | 136 | ?> |
137 | 137 | <tr valign="top"> |
138 | 138 | <th></th> |
139 | 139 | <th> |
140 | 140 | <input type="submit" |
141 | - class="button button-primary button-large button-secondary <?php echo 'step-' . $step; ?>" |
|
141 | + class="button button-primary button-large button-secondary <?php echo 'step-'.$step; ?>" |
|
142 | 142 | id="recount-stats-submit" |
143 | - value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/> |
|
143 | + value="<?php esc_attr_e('Submit', 'give'); ?>"/> |
|
144 | 144 | </th> |
145 | 145 | </tr> |
146 | 146 | <?php |
@@ -154,38 +154,38 @@ discard block |
||
154 | 154 | |
155 | 155 | static function import_success() { |
156 | 156 | |
157 | - $delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false ); |
|
158 | - $csv = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false ); |
|
159 | - if ( ! empty( $delete_csv ) && ! empty( $csv ) ) { |
|
160 | - wp_delete_attachment( $csv, true ); |
|
157 | + $delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false); |
|
158 | + $csv = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false); |
|
159 | + if ( ! empty($delete_csv) && ! empty($csv)) { |
|
160 | + wp_delete_attachment($csv, true); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | $report = give_import_donation_report(); |
164 | 164 | $report_html = array( |
165 | 165 | 'duplicate_donor' => array( |
166 | - __( '%s duplicate %s detected', 'give' ), |
|
167 | - __( 'donor', 'give' ), |
|
168 | - __( 'donors', 'give' ), |
|
166 | + __('%s duplicate %s detected', 'give'), |
|
167 | + __('donor', 'give'), |
|
168 | + __('donors', 'give'), |
|
169 | 169 | ), |
170 | 170 | 'create_donor' => array( |
171 | - __( '%s %s created', 'give' ), |
|
172 | - __( 'donor', 'give' ), |
|
173 | - __( 'donors', 'give' ), |
|
171 | + __('%s %s created', 'give'), |
|
172 | + __('donor', 'give'), |
|
173 | + __('donors', 'give'), |
|
174 | 174 | ), |
175 | 175 | 'create_form' => array( |
176 | - __( '%s donation %s created', 'give' ), |
|
177 | - __( 'form', 'give' ), |
|
178 | - __( 'forms', 'give' ), |
|
176 | + __('%s donation %s created', 'give'), |
|
177 | + __('form', 'give'), |
|
178 | + __('forms', 'give'), |
|
179 | 179 | ), |
180 | 180 | 'duplicate_donation' => array( |
181 | - __( '%s duplicate %s detected', 'give' ), |
|
182 | - __( 'donation', 'give' ), |
|
183 | - __( 'donations', 'give' ), |
|
181 | + __('%s duplicate %s detected', 'give'), |
|
182 | + __('donation', 'give'), |
|
183 | + __('donations', 'give'), |
|
184 | 184 | ), |
185 | 185 | 'create_donation' => array( |
186 | - __( '%s %s imported', 'give' ), |
|
187 | - __( 'donation', 'give' ), |
|
188 | - __( 'donations', 'give' ), |
|
186 | + __('%s %s imported', 'give'), |
|
187 | + __('donation', 'give'), |
|
188 | + __('donations', 'give'), |
|
189 | 189 | ), |
190 | 190 | ); |
191 | 191 | $total = (int) $_GET['total']; |
@@ -196,34 +196,34 @@ discard block |
||
196 | 196 | <th colspan="2"> |
197 | 197 | <h2> |
198 | 198 | <?php |
199 | - if ( $success ) { |
|
200 | - echo sprintf( __( 'Import complete! %s donations processed', 'give' ), "<strong>{$total}</strong>" ); |
|
199 | + if ($success) { |
|
200 | + echo sprintf(__('Import complete! %s donations processed', 'give'), "<strong>{$total}</strong>"); |
|
201 | 201 | } else { |
202 | - echo sprintf( __( 'Failed to import %s donations', 'give' ), "<strong>{$total}</strong>" ); |
|
202 | + echo sprintf(__('Failed to import %s donations', 'give'), "<strong>{$total}</strong>"); |
|
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | </h2> |
206 | 206 | |
207 | 207 | <?php |
208 | - $text = __( 'Import Donation', 'give' ); |
|
208 | + $text = __('Import Donation', 'give'); |
|
209 | 209 | $query_arg = array( |
210 | 210 | 'post_type' => 'give_forms', |
211 | 211 | 'page' => 'give-tools', |
212 | 212 | 'tab' => 'import', |
213 | 213 | ); |
214 | - if ( $success ) { |
|
214 | + if ($success) { |
|
215 | 215 | $query_arg = array( |
216 | 216 | 'post_type' => 'give_forms', |
217 | 217 | 'page' => 'give-payment-history', |
218 | 218 | ); |
219 | - $text = __( 'View Donations', 'give' ); |
|
219 | + $text = __('View Donations', 'give'); |
|
220 | 220 | } |
221 | 221 | |
222 | - foreach ( $report as $key => $value ) { |
|
223 | - if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) { |
|
222 | + foreach ($report as $key => $value) { |
|
223 | + if (array_key_exists($key, $report_html) && ! empty($value)) { |
|
224 | 224 | ?> |
225 | 225 | <p> |
226 | - <?php echo esc_html( wp_sprintf( $report_html[ $key ][0], $value, _n( $report_html[ $key ][1], $report_html[ $key ][2], $value, 'give' ) ) ); ?> |
|
226 | + <?php echo esc_html(wp_sprintf($report_html[$key][0], $value, _n($report_html[$key][1], $report_html[$key][2], $value, 'give'))); ?> |
|
227 | 227 | </p> |
228 | 228 | <?php |
229 | 229 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | ?> |
232 | 232 | |
233 | 233 | <p> |
234 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
234 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
235 | 235 | </p> |
236 | 236 | </th> |
237 | 237 | </tr> |
@@ -249,22 +249,22 @@ discard block |
||
249 | 249 | $index_start = 1; |
250 | 250 | $index_end = 1; |
251 | 251 | $next = true; |
252 | - $total = self::get_csv_total( $csv ); |
|
253 | - if ( self::$per_page < $total ) { |
|
254 | - $total_ajax = ceil( $total / self::$per_page ); |
|
252 | + $total = self::get_csv_total($csv); |
|
253 | + if (self::$per_page < $total) { |
|
254 | + $total_ajax = ceil($total / self::$per_page); |
|
255 | 255 | $index_end = self::$per_page; |
256 | 256 | } else { |
257 | 257 | $total_ajax = 1; |
258 | 258 | $index_end = $total; |
259 | 259 | $next = false; |
260 | 260 | } |
261 | - $current_percentage = 100 / ( $total_ajax + 1 ); |
|
261 | + $current_percentage = 100 / ($total_ajax + 1); |
|
262 | 262 | |
263 | 263 | ?> |
264 | 264 | <tr valign="top" class="give-import-dropdown"> |
265 | 265 | <th colspan="2"> |
266 | - <h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2> |
|
267 | - <p class="give-field-description"><?php esc_html_e( 'Your donations are now being imported...', 'give' ) ?></p> |
|
266 | + <h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2> |
|
267 | + <p class="give-field-description"><?php esc_html_e('Your donations are now being imported...', 'give') ?></p> |
|
268 | 268 | </th> |
269 | 269 | </tr> |
270 | 270 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | <div style="width: <?php echo $current_percentage; ?>%"></div> |
284 | 284 | </div> |
285 | 285 | <input type="hidden" value="3" name="step"> |
286 | - <input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto" |
|
286 | + <input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto" |
|
287 | 287 | class="mapto"> |
288 | 288 | <input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv"> |
289 | 289 | <input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode"> |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | <input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv" |
293 | 293 | class="delete_csv"> |
294 | 294 | <input type="hidden" value="<?php echo $_REQUEST['delimiter']; ?>" name="delimiter"> |
295 | - <input type="hidden" value='<?php echo maybe_serialize( self::get_importer( $csv ) ); ?>' |
|
295 | + <input type="hidden" value='<?php echo maybe_serialize(self::get_importer($csv)); ?>' |
|
296 | 296 | name="main_key" |
297 | 297 | class="main_key"> |
298 | 298 | </th> |
@@ -313,20 +313,20 @@ discard block |
||
313 | 313 | */ |
314 | 314 | static function check_for_dropdown_or_import() { |
315 | 315 | $return = true; |
316 | - if ( isset( $_REQUEST['mapto'] ) ) { |
|
316 | + if (isset($_REQUEST['mapto'])) { |
|
317 | 317 | $mapto = (array) $_REQUEST['mapto']; |
318 | - if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) { |
|
319 | - Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'Please select Form ID or Form Name options from the dropdown.', 'give' ) ); |
|
318 | + if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) { |
|
319 | + Give_Admin_Settings::add_error('give-import-csv-form', __('Please select Form ID or Form Name options from the dropdown.', 'give')); |
|
320 | 320 | $return = false; |
321 | 321 | } |
322 | 322 | |
323 | - if ( false === in_array( 'amount', $mapto ) ) { |
|
324 | - Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'Please select Amount option from the dropdown.', 'give' ) ); |
|
323 | + if (false === in_array('amount', $mapto)) { |
|
324 | + Give_Admin_Settings::add_error('give-import-csv-amount', __('Please select Amount option from the dropdown.', 'give')); |
|
325 | 325 | $return = false; |
326 | 326 | } |
327 | 327 | |
328 | - if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) { |
|
329 | - Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'Please select Email id or Customer ID options from the dropdown.', 'give' ) ); |
|
328 | + if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) { |
|
329 | + Give_Admin_Settings::add_error('give-import-csv-donor', __('Please select Email id or Customer ID options from the dropdown.', 'give')); |
|
330 | 330 | $return = false; |
331 | 331 | } |
332 | 332 | } else { |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | $csv = (int) $_GET['csv']; |
346 | 346 | |
347 | 347 | // TO check if the CSV files that is being add is valid or not if not then redirect to first step again |
348 | - $has_error = self::csv_check( $csv ); |
|
349 | - if ( $has_error ) { |
|
348 | + $has_error = self::csv_check($csv); |
|
349 | + if ($has_error) { |
|
350 | 350 | $url = give_import_page_url(); |
351 | 351 | ?> |
352 | 352 | <script type="text/javascript"> |
@@ -357,29 +357,29 @@ discard block |
||
357 | 357 | ?> |
358 | 358 | <tr valign="top" class="give-import-dropdown"> |
359 | 359 | <th colspan="2"> |
360 | - <h2 id="give-import-title"><?php esc_html_e( 'Map CSV fields to donations', 'give' ) ?></h2> |
|
361 | - <p class="give-field-description"><?php esc_html_e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p> |
|
360 | + <h2 id="give-import-title"><?php esc_html_e('Map CSV fields to donations', 'give') ?></h2> |
|
361 | + <p class="give-field-description"><?php esc_html_e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p> |
|
362 | 362 | </th> |
363 | 363 | </tr> |
364 | 364 | |
365 | 365 | <tr valign="top" class="give-import-dropdown"> |
366 | - <th><b><?php esc_html_e( 'Column name', 'give' ); ?></b></th> |
|
367 | - <th><b><?php esc_html_e( 'Map to field', 'give' ); ?></b></th> |
|
366 | + <th><b><?php esc_html_e('Column name', 'give'); ?></b></th> |
|
367 | + <th><b><?php esc_html_e('Map to field', 'give'); ?></b></th> |
|
368 | 368 | </tr> |
369 | 369 | |
370 | 370 | <?php |
371 | - $raw_key = self::get_importer( $csv ); |
|
371 | + $raw_key = self::get_importer($csv); |
|
372 | 372 | $donations = give_import_donations_options(); |
373 | 373 | $donors = give_import_donor_options(); |
374 | 374 | $forms = give_import_donation_form_options(); |
375 | 375 | |
376 | - foreach ( $raw_key as $index => $value ) { |
|
376 | + foreach ($raw_key as $index => $value) { |
|
377 | 377 | ?> |
378 | 378 | <tr valign="top" class="give-import-option"> |
379 | 379 | <th><?php echo $value; ?></th> |
380 | 380 | <th> |
381 | 381 | <?php |
382 | - self::get_columns( $index, $donations, $donors, $forms, $value ); |
|
382 | + self::get_columns($index, $donations, $donors, $forms, $value); |
|
383 | 383 | ?> |
384 | 384 | </th> |
385 | 385 | </tr> |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - static function selected( $option_value, $value ) { |
|
391 | + static function selected($option_value, $value) { |
|
392 | 392 | $selected = ''; |
393 | - if ( stristr( $value, $option_value ) ) { |
|
393 | + if (stristr($value, $option_value)) { |
|
394 | 394 | $selected = 'selected'; |
395 | - } elseif ( strrpos( $value, '_' ) && stristr( $option_value, 'Import as Meta' ) ) { |
|
395 | + } elseif (strrpos($value, '_') && stristr($option_value, 'Import as Meta')) { |
|
396 | 396 | $selected = 'selected'; |
397 | 397 | } |
398 | 398 | |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @since 1.8.13 |
406 | 406 | */ |
407 | - static function get_columns( $index, $donations, $donors, $forms, $value = false ) { |
|
407 | + static function get_columns($index, $donations, $donors, $forms, $value = false) { |
|
408 | 408 | $default = give_import_default_options(); |
409 | 409 | ?> |
410 | 410 | <select name="mapto[<?php echo $index; ?>]"> |
411 | 411 | <?php |
412 | - foreach ( $default as $option => $option_value ) { |
|
413 | - $checked = self::selected( $option_value, $value ); |
|
412 | + foreach ($default as $option => $option_value) { |
|
413 | + $checked = self::selected($option_value, $value); |
|
414 | 414 | ?> |
415 | 415 | <option value="<?php echo $option; ?>" <?php echo $checked; ?> ><?php echo $option_value; ?></option> |
416 | 416 | <?php |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | ?> |
419 | 419 | <optgroup label="Donations"> |
420 | 420 | <?php |
421 | - foreach ( $donations as $option => $option_value ) { |
|
422 | - $checked = self::selected( $option_value, $value ); |
|
421 | + foreach ($donations as $option => $option_value) { |
|
422 | + $checked = self::selected($option_value, $value); |
|
423 | 423 | ?> |
424 | 424 | <option value="<?php echo $option; ?>" <?php echo $checked; ?> ><?php echo $option_value; ?></option> |
425 | 425 | <?php |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | |
430 | 430 | <optgroup label="Donors"> |
431 | 431 | <?php |
432 | - foreach ( $donors as $option => $option_value ) { |
|
433 | - $checked = self::selected( $option_value, $value ); |
|
432 | + foreach ($donors as $option => $option_value) { |
|
433 | + $checked = self::selected($option_value, $value); |
|
434 | 434 | ?> |
435 | 435 | <option value="<?php echo $option; ?>" <?php echo $checked; ?> ><?php echo $option_value; ?></option> |
436 | 436 | <?php |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | |
441 | 441 | <optgroup label="Forms"> |
442 | 442 | <?php |
443 | - foreach ( $forms as $option => $option_value ) { |
|
444 | - $checked = self::selected( $option_value, $value ); |
|
443 | + foreach ($forms as $option => $option_value) { |
|
444 | + $checked = self::selected($option_value, $value); |
|
445 | 445 | ?> |
446 | 446 | <option value="<?php echo $option; ?>" <?php echo $checked; ?> ><?php echo $option_value; ?></option> |
447 | 447 | <?php |
@@ -450,19 +450,19 @@ discard block |
||
450 | 450 | </optgroup> |
451 | 451 | |
452 | 452 | <?php |
453 | - do_action( 'give_import_dropdown_option', $index, $donations, $donors, $forms, $value ); |
|
453 | + do_action('give_import_dropdown_option', $index, $donations, $donors, $forms, $value); |
|
454 | 454 | ?> |
455 | 455 | </select> |
456 | 456 | <?php |
457 | 457 | } |
458 | 458 | |
459 | - static function get_csv_total( $file_id ) { |
|
459 | + static function get_csv_total($file_id) { |
|
460 | 460 | $total = false; |
461 | - if ( $file_id ) { |
|
462 | - $file_dir = get_attached_file( $file_id ); |
|
463 | - if ( $file_dir ) { |
|
464 | - $file = new SplFileObject( $file_dir, 'r' ); |
|
465 | - $file->seek( PHP_INT_MAX ); |
|
461 | + if ($file_id) { |
|
462 | + $file_dir = get_attached_file($file_id); |
|
463 | + if ($file_dir) { |
|
464 | + $file = new SplFileObject($file_dir, 'r'); |
|
465 | + $file->seek(PHP_INT_MAX); |
|
466 | 466 | $total = $file->key() + 1; |
467 | 467 | } |
468 | 468 | } |
@@ -481,15 +481,15 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return array|bool $raw_data title of the CSV file fields |
483 | 483 | */ |
484 | - static function get_importer( $file_id, $index = 0, $delimiter = ',' ) { |
|
484 | + static function get_importer($file_id, $index = 0, $delimiter = ',') { |
|
485 | 485 | $raw_data = false; |
486 | - $file_dir = get_attached_file( $file_id ); |
|
487 | - if ( $file_dir ) { |
|
488 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
489 | - $raw_data = fgetcsv( $handle, $index, $delimiter ); |
|
486 | + $file_dir = get_attached_file($file_id); |
|
487 | + if ($file_dir) { |
|
488 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
489 | + $raw_data = fgetcsv($handle, $index, $delimiter); |
|
490 | 490 | // Remove BOM signature from the first item. |
491 | - if ( isset( $raw_data[0] ) ) { |
|
492 | - $raw_data[0] = self::remove_utf8_bom( $raw_data[0] ); |
|
491 | + if (isset($raw_data[0])) { |
|
492 | + $raw_data[0] = self::remove_utf8_bom($raw_data[0]); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string |
508 | 508 | */ |
509 | - static function remove_utf8_bom( $string ) { |
|
510 | - if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) { |
|
511 | - $string = substr( $string, 3 ); |
|
509 | + static function remove_utf8_bom($string) { |
|
510 | + if ('efbbbf' === substr(bin2hex($string), 0, 6)) { |
|
511 | + $string = substr($string, 3); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | return $string; |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | $step = Give_Settings_Import::get_step(); |
525 | 525 | ?> |
526 | 526 | <ol class="give-progress-steps"> |
527 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"><?php esc_html_e( 'Upload CSV file', 'give' ); ?></li> |
|
528 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"><?php esc_html_e( 'Column mapping', 'give' ); ?></li> |
|
529 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"><?php esc_html_e( 'Import', 'give' ); ?></li> |
|
530 | - <li class="<?php echo( 4 === $step ? 'active' : '' ); ?>"><?php esc_html_e( 'Done!', 'give' ); ?></li> |
|
527 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"><?php esc_html_e('Upload CSV file', 'give'); ?></li> |
|
528 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"><?php esc_html_e('Column mapping', 'give'); ?></li> |
|
529 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"><?php esc_html_e('Import', 'give'); ?></li> |
|
530 | + <li class="<?php echo(4 === $step ? 'active' : ''); ?>"><?php esc_html_e('Done!', 'give'); ?></li> |
|
531 | 531 | </ol> |
532 | 532 | <?php |
533 | 533 | } |
@@ -540,15 +540,15 @@ discard block |
||
540 | 540 | * @return int $step on which step doest the import is on. |
541 | 541 | */ |
542 | 542 | static function get_step() { |
543 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
543 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
544 | 544 | $on_step = 1; |
545 | - if ( empty( $step ) || 1 === $step ) { |
|
545 | + if (empty($step) || 1 === $step) { |
|
546 | 546 | $on_step = 1; |
547 | - } elseif ( self::check_for_dropdown_or_import() ) { |
|
547 | + } elseif (self::check_for_dropdown_or_import()) { |
|
548 | 548 | $on_step = 3; |
549 | - } elseif ( 2 === $step ) { |
|
549 | + } elseif (2 === $step) { |
|
550 | 550 | $on_step = 2; |
551 | - } elseif ( 4 === $step ) { |
|
551 | + } elseif (4 === $step) { |
|
552 | 552 | $on_step = 4; |
553 | 553 | } |
554 | 554 | |
@@ -566,56 +566,56 @@ discard block |
||
566 | 566 | ?> |
567 | 567 | <tr valign="top"> |
568 | 568 | <th colspan="2"> |
569 | - <h2 id="give-import-title"><?php esc_html_e( 'Import donations from a CSV file', 'give' ) ?></h2> |
|
570 | - <p class="give-field-description"><?php esc_html_e( 'This tool allows you to import (or merge) donation data to give from a CSV file.', 'give' ) ?></p> |
|
569 | + <h2 id="give-import-title"><?php esc_html_e('Import donations from a CSV file', 'give') ?></h2> |
|
570 | + <p class="give-field-description"><?php esc_html_e('This tool allows you to import (or merge) donation data to give from a CSV file.', 'give') ?></p> |
|
571 | 571 | </th> |
572 | 572 | </tr> |
573 | 573 | <?php |
574 | - $csv = ( isset( $_REQUEST['csv'] ) ? give_clean( $_POST['csv'] ) : '' ); |
|
575 | - $delimiter = ( isset( $_REQUEST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : ',' ); |
|
576 | - $mode = ( ! empty( $_REQUEST['mode'] ) ? 'on' : '' ); |
|
577 | - $create_user = ( isset( $_REQUEST['create_user'] ) && isset( $_REQUEST['csv'] ) && 1 == absint( $_REQUEST['create_user'] ) ? 'on' : ( isset( $_REQUEST['csv'] ) ? '' : 'on' ) ); |
|
578 | - $delete_csv = ( isset( $_REQUEST['delete_csv'] ) && isset( $_REQUEST['csv'] ) && 1 == absint( $_REQUEST['delete_csv'] ) ? 'on' : ( isset( $_REQUEST['csv'] ) ? '' : 'on' ) ); |
|
574 | + $csv = (isset($_REQUEST['csv']) ? give_clean($_POST['csv']) : ''); |
|
575 | + $delimiter = (isset($_REQUEST['delimiter']) ? give_clean($_POST['delimiter']) : ','); |
|
576 | + $mode = ( ! empty($_REQUEST['mode']) ? 'on' : ''); |
|
577 | + $create_user = (isset($_REQUEST['create_user']) && isset($_REQUEST['csv']) && 1 == absint($_REQUEST['create_user']) ? 'on' : (isset($_REQUEST['csv']) ? '' : 'on')); |
|
578 | + $delete_csv = (isset($_REQUEST['delete_csv']) && isset($_REQUEST['csv']) && 1 == absint($_REQUEST['delete_csv']) ? 'on' : (isset($_REQUEST['csv']) ? '' : 'on')); |
|
579 | 579 | |
580 | 580 | $settings = array( |
581 | 581 | array( |
582 | 582 | 'id' => 'csv', |
583 | - 'name' => __( 'Choose a CSV file:', 'give' ), |
|
583 | + 'name' => __('Choose a CSV file:', 'give'), |
|
584 | 584 | 'type' => 'file', |
585 | - 'attributes' => array( 'editing' => 'false', 'library' => 'text' ), |
|
585 | + 'attributes' => array('editing' => 'false', 'library' => 'text'), |
|
586 | 586 | 'fvalue' => 'id', |
587 | 587 | 'default' => $csv, |
588 | 588 | ), |
589 | 589 | array( |
590 | 590 | 'id' => 'delimiter', |
591 | - 'name' => __( 'CSV Delimiter:', 'give' ), |
|
591 | + 'name' => __('CSV Delimiter:', 'give'), |
|
592 | 592 | 'type' => 'text', |
593 | - 'attributes' => array( 'placeholder' => ',', 'size' => '2' ), |
|
593 | + 'attributes' => array('placeholder' => ',', 'size' => '2'), |
|
594 | 594 | 'default' => $delimiter, |
595 | 595 | ), |
596 | 596 | array( |
597 | 597 | 'id' => 'mode', |
598 | - 'name' => __( 'Test Mode:', 'give' ), |
|
598 | + 'name' => __('Test Mode:', 'give'), |
|
599 | 599 | 'type' => 'checkbox', |
600 | 600 | 'default' => $mode, |
601 | 601 | ), |
602 | 602 | array( |
603 | 603 | 'id' => 'create_user', |
604 | - 'name' => __( 'Create WP users for new donors?:', 'give' ), |
|
604 | + 'name' => __('Create WP users for new donors?:', 'give'), |
|
605 | 605 | 'type' => 'checkbox', |
606 | 606 | 'default' => $create_user, |
607 | 607 | ), |
608 | 608 | array( |
609 | 609 | 'id' => 'delete_csv', |
610 | - 'name' => __( 'Delete CSV after import:', 'give' ), |
|
610 | + 'name' => __('Delete CSV after import:', 'give'), |
|
611 | 611 | 'type' => 'checkbox', |
612 | 612 | 'default' => $delete_csv, |
613 | 613 | ), |
614 | 614 | ); |
615 | 615 | |
616 | - $settings = apply_filters( 'give_import_file_upload_html', $settings ); |
|
616 | + $settings = apply_filters('give_import_file_upload_html', $settings); |
|
617 | 617 | |
618 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
618 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | $step = Give_Settings_Import::get_step(); |
629 | 629 | |
630 | 630 | // Validation for first step. |
631 | - if ( 1 === $step ) { |
|
632 | - $csv = absint( $_POST['csv'] ); |
|
631 | + if (1 === $step) { |
|
632 | + $csv = absint($_POST['csv']); |
|
633 | 633 | |
634 | - $has_error = self::csv_check( $csv ); |
|
634 | + $has_error = self::csv_check($csv); |
|
635 | 635 | |
636 | - if ( false == $has_error ) { |
|
636 | + if (false == $has_error) { |
|
637 | 637 | |
638 | - $url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array( |
|
638 | + $url = give_import_page_url((array) apply_filters('give_import_step_two_url', array( |
|
639 | 639 | 'step' => '2', |
640 | 640 | 'csv' => $csv, |
641 | - 'delimiter' => ( isset( $_REQUEST['delimiter'] ) ) ? give_clean( $_REQUEST['delimiter'] ) : ',', |
|
642 | - 'mode' => ( isset( $_REQUEST['mode'] ) ) ? give_clean( $_REQUEST['mode'] ) : '0', |
|
643 | - 'create_user' => ( isset( $_REQUEST['create_user'] ) ) ? give_clean( $_REQUEST['create_user'] ) : '0', |
|
644 | - 'delete_csv' => ( isset( $_REQUEST['delete_csv'] ) ) ? give_clean( $_REQUEST['delete_csv'] ) : '0', |
|
645 | - ) ) ); |
|
641 | + 'delimiter' => (isset($_REQUEST['delimiter'])) ? give_clean($_REQUEST['delimiter']) : ',', |
|
642 | + 'mode' => (isset($_REQUEST['mode'])) ? give_clean($_REQUEST['mode']) : '0', |
|
643 | + 'create_user' => (isset($_REQUEST['create_user'])) ? give_clean($_REQUEST['create_user']) : '0', |
|
644 | + 'delete_csv' => (isset($_REQUEST['delete_csv'])) ? give_clean($_REQUEST['delete_csv']) : '0', |
|
645 | + ))); |
|
646 | 646 | ?> |
647 | 647 | <script type="text/javascript"> |
648 | 648 | window.location = "<?php echo $url; ?>" |
@@ -661,19 +661,19 @@ discard block |
||
661 | 661 | * |
662 | 662 | * return bool $has_error CSV is valid or not. |
663 | 663 | */ |
664 | - static function csv_check( $csv = false ) { |
|
664 | + static function csv_check($csv = false) { |
|
665 | 665 | $has_error = false; |
666 | - if ( $csv ) { |
|
667 | - if ( ! wp_get_attachment_url( $csv ) ) { |
|
666 | + if ($csv) { |
|
667 | + if ( ! wp_get_attachment_url($csv)) { |
|
668 | 668 | $has_error = true; |
669 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide the ID to a valid CSV file.', 'give' ) ); |
|
670 | - } elseif ( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, 'csv' ) ) { |
|
669 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide the ID to a valid CSV file.', 'give')); |
|
670 | + } elseif (($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, 'csv')) { |
|
671 | 671 | $has_error = true; |
672 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide the ID to a valid CSV file.', 'give' ) ); |
|
672 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide the ID to a valid CSV file.', 'give')); |
|
673 | 673 | } |
674 | 674 | } else { |
675 | 675 | $has_error = true; |
676 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide the ID to a valid CSV file.', 'give' ) ); |
|
676 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide the ID to a valid CSV file.', 'give')); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | return $has_error; |
@@ -688,8 +688,8 @@ discard block |
||
688 | 688 | * |
689 | 689 | * @return array |
690 | 690 | */ |
691 | - public function add_settings_page( $pages ) { |
|
692 | - $pages[ $this->id ] = $this->label; |
|
691 | + public function add_settings_page($pages) { |
|
692 | + $pages[$this->id] = $this->label; |
|
693 | 693 | |
694 | 694 | return $pages; |
695 | 695 | } |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param array $settings |
713 | 713 | */ |
714 | 714 | $settings = apply_filters( |
715 | - 'give_get_settings_' . $this->id, |
|
715 | + 'give_get_settings_'.$this->id, |
|
716 | 716 | array( |
717 | 717 | array( |
718 | 718 | 'id' => 'import', |
719 | - 'name' => __( 'Import Donations', 'give' ), |
|
719 | + 'name' => __('Import Donations', 'give'), |
|
720 | 720 | 'type' => 'tools_import', |
721 | 721 | ), |
722 | 722 | ) |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | */ |
735 | 735 | public function output() { |
736 | 736 | $settings = $this->get_settings(); |
737 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
737 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | * @param $field |
747 | 747 | * @param $option_value |
748 | 748 | */ |
749 | - public function render_import_field( $field, $option_value ) { |
|
750 | - include_once( 'views/html-admin-page-imports.php' ); |
|
749 | + public function render_import_field($field, $option_value) { |
|
750 | + include_once('views/html-admin-page-imports.php'); |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | } |