@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,39 +98,39 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades, false ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades, false); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
118 | + case version_compare($give_version, '2.0.3', '<') : |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | |
122 | - case version_compare( $give_version, '2.2.0', '<' ) : |
|
122 | + case version_compare($give_version, '2.2.0', '<') : |
|
123 | 123 | give_v220_upgrades(); |
124 | 124 | $did_upgrade = true; |
125 | 125 | } |
126 | 126 | |
127 | - if ( $did_upgrade ) { |
|
128 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
127 | + if ($did_upgrade) { |
|
128 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
133 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
132 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
133 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Display Upgrade Notices. |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return void |
146 | 146 | */ |
147 | -function give_show_upgrade_notices( $give_updates ) { |
|
147 | +function give_show_upgrade_notices($give_updates) { |
|
148 | 148 | // v1.3.2 Upgrades |
149 | 149 | $give_updates->register( |
150 | 150 | array( |
@@ -210,32 +210,32 @@ discard block |
||
210 | 210 | ); |
211 | 211 | |
212 | 212 | // v1.8.17 Upgrades for donations. |
213 | - $give_updates->register( array( |
|
213 | + $give_updates->register(array( |
|
214 | 214 | 'id' => 'v1817_update_donation_iranian_currency_code', |
215 | 215 | 'version' => '1.8.17', |
216 | 216 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
217 | - ) ); |
|
217 | + )); |
|
218 | 218 | |
219 | 219 | // v1.8.17 Upgrades for cleanup of user roles. |
220 | - $give_updates->register( array( |
|
220 | + $give_updates->register(array( |
|
221 | 221 | 'id' => 'v1817_cleanup_user_roles', |
222 | 222 | 'version' => '1.8.17', |
223 | 223 | 'callback' => 'give_v1817_cleanup_user_roles', |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | |
226 | 226 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
227 | - $give_updates->register( array( |
|
227 | + $give_updates->register(array( |
|
228 | 228 | 'id' => 'v1818_assign_custom_amount_set_donation', |
229 | 229 | 'version' => '1.8.18', |
230 | 230 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
231 | - ) ); |
|
231 | + )); |
|
232 | 232 | |
233 | 233 | // v1.8.18 Cleanup the Give Worker Role Caps. |
234 | - $give_updates->register( array( |
|
234 | + $give_updates->register(array( |
|
235 | 235 | 'id' => 'v1818_give_worker_role_cleanup', |
236 | 236 | 'version' => '1.8.18', |
237 | 237 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
238 | - ) ); |
|
238 | + )); |
|
239 | 239 | |
240 | 240 | // v2.0.0 Upgrades |
241 | 241 | $give_updates->register( |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'id' => 'v20_move_metadata_into_new_table', |
290 | 290 | 'version' => '2.0.0', |
291 | 291 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
292 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
292 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
293 | 293 | ) |
294 | 294 | ); |
295 | 295 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | 'id' => 'v201_move_metadata_into_new_table', |
336 | 336 | 'version' => '2.0.1', |
337 | 337 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
338 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
338 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'id' => 'v213_delete_donation_meta', |
364 | 364 | 'version' => '2.1.3', |
365 | 365 | 'callback' => 'give_v213_delete_donation_meta_callback', |
366 | - 'depends' => array( 'v201_move_metadata_into_new_table' ) |
|
366 | + 'depends' => array('v201_move_metadata_into_new_table') |
|
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ); |
378 | 378 | } |
379 | 379 | |
380 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
380 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * Triggers all upgrade functions |
@@ -389,29 +389,29 @@ discard block |
||
389 | 389 | */ |
390 | 390 | function give_trigger_upgrades() { |
391 | 391 | |
392 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
393 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
392 | + if ( ! current_user_can('manage_give_settings')) { |
|
393 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
394 | 394 | 'response' => 403, |
395 | - ) ); |
|
395 | + )); |
|
396 | 396 | } |
397 | 397 | |
398 | - $give_version = get_option( 'give_version' ); |
|
398 | + $give_version = get_option('give_version'); |
|
399 | 399 | |
400 | - if ( ! $give_version ) { |
|
400 | + if ( ! $give_version) { |
|
401 | 401 | // 1.0 is the first version to use this option so we must add it. |
402 | 402 | $give_version = '1.0'; |
403 | - add_option( 'give_version', $give_version, '', false ); |
|
403 | + add_option('give_version', $give_version, '', false); |
|
404 | 404 | } |
405 | 405 | |
406 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
407 | - delete_option( 'give_doing_upgrade' ); |
|
406 | + update_option('give_version', GIVE_VERSION, false); |
|
407 | + delete_option('give_doing_upgrade'); |
|
408 | 408 | |
409 | - if ( DOING_AJAX ) { |
|
410 | - die( 'complete' ); |
|
409 | + if (DOING_AJAX) { |
|
410 | + die('complete'); |
|
411 | 411 | } // End if(). |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
414 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
415 | 415 | |
416 | 416 | |
417 | 417 | /** |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | |
430 | 430 | // UPDATE DB METAKEYS. |
431 | 431 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
432 | - $query = $wpdb->query( $sql ); |
|
432 | + $query = $wpdb->query($sql); |
|
433 | 433 | |
434 | 434 | $give_updates->percentage = 100; |
435 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
435 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -456,24 +456,24 @@ discard block |
||
456 | 456 | $where .= "AND ( p.post_status = 'abandoned' )"; |
457 | 457 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
458 | 458 | |
459 | - $sql = $select . $join . $where; |
|
460 | - $found_payments = $wpdb->get_col( $sql ); |
|
459 | + $sql = $select.$join.$where; |
|
460 | + $found_payments = $wpdb->get_col($sql); |
|
461 | 461 | |
462 | - foreach ( $found_payments as $payment ) { |
|
462 | + foreach ($found_payments as $payment) { |
|
463 | 463 | |
464 | 464 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
465 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
465 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
466 | 466 | |
467 | 467 | // 1450124863 = 12/10/2015 20:42:25. |
468 | - if ( $modified_time >= 1450124863 ) { |
|
468 | + if ($modified_time >= 1450124863) { |
|
469 | 469 | |
470 | - give_update_payment_status( $payment, 'pending' ); |
|
470 | + give_update_payment_status($payment, 'pending'); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | 475 | $give_updates->percentage = 100; |
476 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
476 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -486,17 +486,17 @@ discard block |
||
486 | 486 | */ |
487 | 487 | function give_v152_cleanup_users() { |
488 | 488 | |
489 | - $give_version = get_option( 'give_version' ); |
|
489 | + $give_version = get_option('give_version'); |
|
490 | 490 | |
491 | - if ( ! $give_version ) { |
|
491 | + if ( ! $give_version) { |
|
492 | 492 | // 1.0 is the first version to use this option so we must add it. |
493 | 493 | $give_version = '1.0'; |
494 | 494 | } |
495 | 495 | |
496 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
496 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
497 | 497 | |
498 | 498 | // v1.5.2 Upgrades |
499 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
499 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
500 | 500 | |
501 | 501 | // Delete all caps with "ss". |
502 | 502 | // Also delete all unused "campaign" roles. |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | ); |
544 | 544 | |
545 | 545 | global $wp_roles; |
546 | - foreach ( $delete_caps as $cap ) { |
|
547 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
548 | - $wp_roles->remove_cap( $role, $cap ); |
|
546 | + foreach ($delete_caps as $cap) { |
|
547 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
548 | + $wp_roles->remove_cap($role, $cap); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | $roles->add_caps(); |
556 | 556 | |
557 | 557 | // The Update Ran. |
558 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
559 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
560 | - delete_option( 'give_doing_upgrade' ); |
|
558 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
559 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
560 | + delete_option('give_doing_upgrade'); |
|
561 | 561 | |
562 | 562 | }// End if(). |
563 | 563 | |
564 | 564 | } |
565 | 565 | |
566 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
566 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
567 | 567 | |
568 | 568 | /** |
569 | 569 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -606,53 +606,53 @@ discard block |
||
606 | 606 | |
607 | 607 | // Get addons license key. |
608 | 608 | $addons = array(); |
609 | - foreach ( $give_options as $key => $value ) { |
|
610 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
611 | - $addons[ $key ] = $value; |
|
609 | + foreach ($give_options as $key => $value) { |
|
610 | + if (false !== strpos($key, '_license_key')) { |
|
611 | + $addons[$key] = $value; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Bailout: We do not have any addon license data to upgrade. |
616 | - if ( empty( $addons ) ) { |
|
616 | + if (empty($addons)) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | - foreach ( $addons as $key => $addon_license ) { |
|
620 | + foreach ($addons as $key => $addon_license) { |
|
621 | 621 | |
622 | 622 | // Get addon shortname. |
623 | - $shortname = str_replace( '_license_key', '', $key ); |
|
623 | + $shortname = str_replace('_license_key', '', $key); |
|
624 | 624 | |
625 | 625 | // Addon license option name. |
626 | - $addon_license_option_name = $shortname . '_license_active'; |
|
626 | + $addon_license_option_name = $shortname.'_license_active'; |
|
627 | 627 | |
628 | 628 | // bailout if license is empty. |
629 | - if ( empty( $addon_license ) ) { |
|
630 | - delete_option( $addon_license_option_name ); |
|
629 | + if (empty($addon_license)) { |
|
630 | + delete_option($addon_license_option_name); |
|
631 | 631 | continue; |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Get addon name. |
635 | 635 | $addon_name = array(); |
636 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
637 | - foreach ( $addon_name_parts as $name_part ) { |
|
636 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
637 | + foreach ($addon_name_parts as $name_part) { |
|
638 | 638 | |
639 | 639 | // Fix addon name |
640 | - switch ( $name_part ) { |
|
640 | + switch ($name_part) { |
|
641 | 641 | case 'authorizenet' : |
642 | 642 | $name_part = 'authorize.net'; |
643 | 643 | break; |
644 | 644 | } |
645 | 645 | |
646 | - $addon_name[] = ucfirst( $name_part ); |
|
646 | + $addon_name[] = ucfirst($name_part); |
|
647 | 647 | } |
648 | 648 | |
649 | - $addon_name = implode( ' ', $addon_name ); |
|
649 | + $addon_name = implode(' ', $addon_name); |
|
650 | 650 | |
651 | 651 | // Data to send to the API. |
652 | 652 | $api_params = array( |
653 | 653 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
654 | 654 | 'license' => $addon_license, |
655 | - 'item_name' => urlencode( $addon_name ), |
|
655 | + 'item_name' => urlencode($addon_name), |
|
656 | 656 | 'url' => home_url(), |
657 | 657 | ); |
658 | 658 | |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | ); |
668 | 668 | |
669 | 669 | // Make sure there are no errors. |
670 | - if ( is_wp_error( $response ) ) { |
|
671 | - delete_option( $addon_license_option_name ); |
|
670 | + if (is_wp_error($response)) { |
|
671 | + delete_option($addon_license_option_name); |
|
672 | 672 | continue; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // Tell WordPress to look for updates. |
676 | - set_site_transient( 'update_plugins', null ); |
|
676 | + set_site_transient('update_plugins', null); |
|
677 | 677 | |
678 | 678 | // Decode license data. |
679 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
680 | - update_option( $addon_license_option_name, $license_data, false ); |
|
679 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
680 | + update_option($addon_license_option_name, $license_data, false); |
|
681 | 681 | }// End foreach(). |
682 | 682 | } |
683 | 683 | |
@@ -707,9 +707,9 @@ discard block |
||
707 | 707 | ); |
708 | 708 | |
709 | 709 | global $wp_roles; |
710 | - foreach ( $delete_caps as $cap ) { |
|
711 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
712 | - $wp_roles->remove_cap( $role, $cap ); |
|
710 | + foreach ($delete_caps as $cap) { |
|
711 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
712 | + $wp_roles->remove_cap($role, $cap); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | function give_v18_upgrades_core_setting() { |
744 | 744 | // Core settings which changes from checkbox to radio. |
745 | 745 | $core_setting_names = array_merge( |
746 | - array_keys( give_v18_renamed_core_settings() ), |
|
746 | + array_keys(give_v18_renamed_core_settings()), |
|
747 | 747 | array( |
748 | 748 | 'uninstall_on_delete', |
749 | 749 | 'scripts_footer', |
@@ -755,48 +755,48 @@ discard block |
||
755 | 755 | ); |
756 | 756 | |
757 | 757 | // Bailout: If not any setting define. |
758 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
758 | + if ($give_settings = get_option('give_settings')) { |
|
759 | 759 | |
760 | 760 | $setting_changed = false; |
761 | 761 | |
762 | 762 | // Loop: check each setting field. |
763 | - foreach ( $core_setting_names as $setting_name ) { |
|
763 | + foreach ($core_setting_names as $setting_name) { |
|
764 | 764 | // New setting name. |
765 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
765 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
766 | 766 | |
767 | 767 | // Continue: If setting already set. |
768 | 768 | if ( |
769 | - array_key_exists( $new_setting_name, $give_settings ) |
|
770 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
769 | + array_key_exists($new_setting_name, $give_settings) |
|
770 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
771 | 771 | ) { |
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Set checkbox value to radio value. |
776 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
776 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
777 | 777 | |
778 | 778 | // @see https://github.com/WordImpress/Give/issues/1063. |
779 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
779 | + if (false !== strpos($setting_name, 'disable_')) { |
|
780 | 780 | |
781 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
782 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
781 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
782 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
783 | 783 | |
784 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
784 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | // Tell bot to update core setting to db. |
788 | - if ( ! $setting_changed ) { |
|
788 | + if ( ! $setting_changed) { |
|
789 | 789 | $setting_changed = true; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | |
793 | 793 | // Update setting only if they changed. |
794 | - if ( $setting_changed ) { |
|
795 | - update_option( 'give_settings', $give_settings, false ); |
|
794 | + if ($setting_changed) { |
|
795 | + update_option('give_settings', $give_settings, false); |
|
796 | 796 | } |
797 | 797 | }// End if(). |
798 | 798 | |
799 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
799 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $give_updates = Give_Updates::get_instance(); |
811 | 811 | |
812 | 812 | // form query |
813 | - $forms = new WP_Query( array( |
|
813 | + $forms = new WP_Query(array( |
|
814 | 814 | 'paged' => $give_updates->step, |
815 | 815 | 'status' => 'any', |
816 | 816 | 'order' => 'ASC', |
@@ -819,41 +819,41 @@ discard block |
||
819 | 819 | ) |
820 | 820 | ); |
821 | 821 | |
822 | - if ( $forms->have_posts() ) { |
|
823 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
822 | + if ($forms->have_posts()) { |
|
823 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
824 | 824 | |
825 | - while ( $forms->have_posts() ) { |
|
825 | + while ($forms->have_posts()) { |
|
826 | 826 | $forms->the_post(); |
827 | 827 | |
828 | 828 | // Form content. |
829 | 829 | // Note in version 1.8 display content setting split into display content and content placement setting. |
830 | 830 | // You can delete _give_content_option in future. |
831 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
832 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
833 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
834 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
831 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
832 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
833 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
834 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
835 | 835 | |
836 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
837 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
836 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
837 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | // "Disable" Guest Donation. Checkbox. |
841 | 841 | // See: https://github.com/WordImpress/Give/issues/1470. |
842 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
843 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
844 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
842 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
843 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
844 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
845 | 845 | |
846 | 846 | // Offline Donations. |
847 | 847 | // See: https://github.com/WordImpress/Give/issues/1579. |
848 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
849 | - if ( 'no' === $offline_donation ) { |
|
848 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
849 | + if ('no' === $offline_donation) { |
|
850 | 850 | $offline_donation_newval = 'global'; |
851 | - } elseif ( 'yes' === $offline_donation ) { |
|
851 | + } elseif ('yes' === $offline_donation) { |
|
852 | 852 | $offline_donation_newval = 'enabled'; |
853 | 853 | } else { |
854 | 854 | $offline_donation_newval = 'disabled'; |
855 | 855 | } |
856 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
856 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
857 | 857 | |
858 | 858 | // Convert yes/no setting field to enabled/disabled. |
859 | 859 | $form_radio_settings = array( |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | '_give_offline_donation_enable_billing_fields_single', |
874 | 874 | ); |
875 | 875 | |
876 | - foreach ( $form_radio_settings as $meta_key ) { |
|
876 | + foreach ($form_radio_settings as $meta_key) { |
|
877 | 877 | // Get value. |
878 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
878 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
879 | 879 | |
880 | 880 | // Convert meta value only if it is in yes/no/none. |
881 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
881 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
882 | 882 | |
883 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
884 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
883 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
884 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | }// End while(). |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | |
891 | 891 | } else { |
892 | 892 | // No more forms found, finish up. |
893 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
893 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
894 | 894 | } |
895 | 895 | } |
896 | 896 | |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | '%_transient_give_stats_%', |
958 | 958 | 'give_cache%', |
959 | 959 | '%_transient_give_add_ons_feed%', |
960 | - '%_transient__give_ajax_works' . |
|
960 | + '%_transient__give_ajax_works'. |
|
961 | 961 | '%_transient_give_total_api_keys%', |
962 | 962 | '%_transient_give_i18n_give_promo_hide%', |
963 | 963 | '%_transient_give_contributors%', |
@@ -984,24 +984,24 @@ discard block |
||
984 | 984 | ARRAY_A |
985 | 985 | ); |
986 | 986 | |
987 | - if ( ! empty( $user_apikey_options ) ) { |
|
988 | - foreach ( $user_apikey_options as $user ) { |
|
989 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
990 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
991 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
987 | + if ( ! empty($user_apikey_options)) { |
|
988 | + foreach ($user_apikey_options as $user) { |
|
989 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
990 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
991 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | - if ( ! empty( $cached_options ) ) { |
|
996 | - foreach ( $cached_options as $option ) { |
|
997 | - switch ( true ) { |
|
998 | - case ( false !== strpos( $option, 'transient' ) ): |
|
999 | - $option = str_replace( '_transient_', '', $option ); |
|
1000 | - delete_transient( $option ); |
|
995 | + if ( ! empty($cached_options)) { |
|
996 | + foreach ($cached_options as $option) { |
|
997 | + switch (true) { |
|
998 | + case (false !== strpos($option, 'transient')): |
|
999 | + $option = str_replace('_transient_', '', $option); |
|
1000 | + delete_transient($option); |
|
1001 | 1001 | break; |
1002 | 1002 | |
1003 | 1003 | default: |
1004 | - delete_option( $option ); |
|
1004 | + delete_option($option); |
|
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | } |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | global $wp_roles; |
1020 | 1020 | |
1021 | 1021 | // Get the role object. |
1022 | - $give_worker = get_role( 'give_worker' ); |
|
1022 | + $give_worker = get_role('give_worker'); |
|
1023 | 1023 | |
1024 | 1024 | // A list of capabilities to add for give workers. |
1025 | 1025 | $caps_to_add = array( |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | 'edit_pages', |
1028 | 1028 | ); |
1029 | 1029 | |
1030 | - foreach ( $caps_to_add as $cap ) { |
|
1030 | + foreach ($caps_to_add as $cap) { |
|
1031 | 1031 | // Add the capability. |
1032 | - $give_worker->add_cap( $cap ); |
|
1032 | + $give_worker->add_cap($cap); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | } |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | $give_updates = Give_Updates::get_instance(); |
1047 | 1047 | |
1048 | 1048 | // form query. |
1049 | - $donation_forms = new WP_Query( array( |
|
1049 | + $donation_forms = new WP_Query(array( |
|
1050 | 1050 | 'paged' => $give_updates->step, |
1051 | 1051 | 'status' => 'any', |
1052 | 1052 | 'order' => 'ASC', |
@@ -1055,10 +1055,10 @@ discard block |
||
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | |
1058 | - if ( $donation_forms->have_posts() ) { |
|
1059 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1058 | + if ($donation_forms->have_posts()) { |
|
1059 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1060 | 1060 | |
1061 | - while ( $donation_forms->have_posts() ) { |
|
1061 | + while ($donation_forms->have_posts()) { |
|
1062 | 1062 | $donation_forms->the_post(); |
1063 | 1063 | $form_id = get_the_ID(); |
1064 | 1064 | |
@@ -1066,41 +1066,41 @@ discard block |
||
1066 | 1066 | update_post_meta( |
1067 | 1067 | $form_id, |
1068 | 1068 | '_give_set_price', |
1069 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1069 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1070 | 1070 | ); |
1071 | 1071 | |
1072 | 1072 | // Remove formatting from _give_custom_amount_minimum. |
1073 | 1073 | update_post_meta( |
1074 | 1074 | $form_id, |
1075 | 1075 | '_give_custom_amount_minimum', |
1076 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1076 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1077 | 1077 | ); |
1078 | 1078 | |
1079 | 1079 | // Bailout. |
1080 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1080 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1081 | 1081 | continue; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1084 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1085 | 1085 | |
1086 | - if ( ! empty( $donation_levels ) ) { |
|
1086 | + if ( ! empty($donation_levels)) { |
|
1087 | 1087 | |
1088 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1089 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1090 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1088 | + foreach ($donation_levels as $index => $donation_level) { |
|
1089 | + if (isset($donation_level['_give_amount'])) { |
|
1090 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1091 | 1091 | } |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1094 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1095 | 1095 | |
1096 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1096 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1097 | 1097 | |
1098 | - $min_amount = min( $donation_levels_amounts ); |
|
1099 | - $max_amount = max( $donation_levels_amounts ); |
|
1098 | + $min_amount = min($donation_levels_amounts); |
|
1099 | + $max_amount = max($donation_levels_amounts); |
|
1100 | 1100 | |
1101 | 1101 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1102 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1103 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1102 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1103 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | } |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | wp_reset_postdata(); |
1110 | 1110 | } else { |
1111 | 1111 | // The Update Ran. |
1112 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1112 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | function give_v20_upgrades() { |
1161 | 1161 | // Update cache setting. |
1162 | - give_update_option( 'cache', 'enabled' ); |
|
1162 | + give_update_option('cache', 'enabled'); |
|
1163 | 1163 | |
1164 | 1164 | // Upgrade email settings. |
1165 | 1165 | give_v20_upgrades_email_setting(); |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $all_setting = give_get_settings(); |
1179 | 1179 | |
1180 | 1180 | // Bailout on fresh install. |
1181 | - if ( empty( $all_setting ) ) { |
|
1181 | + if (empty($all_setting)) { |
|
1182 | 1182 | return; |
1183 | 1183 | } |
1184 | 1184 | |
@@ -1197,19 +1197,19 @@ discard block |
||
1197 | 1197 | 'admin_notices' => 'new-donation_notification', |
1198 | 1198 | ); |
1199 | 1199 | |
1200 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1200 | + foreach ($settings as $old_setting => $new_setting) { |
|
1201 | 1201 | // Do not update already modified |
1202 | - if ( ! is_array( $new_setting ) ) { |
|
1203 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1202 | + if ( ! is_array($new_setting)) { |
|
1203 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1204 | 1204 | continue; |
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - switch ( $old_setting ) { |
|
1208 | + switch ($old_setting) { |
|
1209 | 1209 | case 'admin_notices': |
1210 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1210 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1211 | 1211 | |
1212 | - give_update_option( $new_setting, $notification_status ); |
|
1212 | + give_update_option($new_setting, $notification_status); |
|
1213 | 1213 | |
1214 | 1214 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1215 | 1215 | // give_delete_option( $old_setting ); |
@@ -1220,19 +1220,19 @@ discard block |
||
1220 | 1220 | case 'admin_notice_emails': |
1221 | 1221 | $recipients = give_get_admin_notice_emails(); |
1222 | 1222 | |
1223 | - foreach ( $new_setting as $setting ) { |
|
1223 | + foreach ($new_setting as $setting) { |
|
1224 | 1224 | // bailout if setting already exist. |
1225 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1225 | + if (array_key_exists($setting, $all_setting)) { |
|
1226 | 1226 | continue; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - give_update_option( $setting, $recipients ); |
|
1229 | + give_update_option($setting, $recipients); |
|
1230 | 1230 | } |
1231 | 1231 | break; |
1232 | 1232 | |
1233 | 1233 | default: |
1234 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1235 | - give_delete_option( $old_setting ); |
|
1234 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1235 | + give_delete_option($old_setting); |
|
1236 | 1236 | } |
1237 | 1237 | } |
1238 | 1238 | } |
@@ -1249,22 +1249,22 @@ discard block |
||
1249 | 1249 | $give_settings = give_get_settings(); |
1250 | 1250 | $give_setting_updated = false; |
1251 | 1251 | |
1252 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1252 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1253 | 1253 | $give_settings['number_decimals'] = 0; |
1254 | 1254 | $give_settings['decimal_separator'] = ''; |
1255 | 1255 | $give_setting_updated = true; |
1256 | 1256 | |
1257 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1257 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1258 | 1258 | $give_settings['number_decimals'] = 0; |
1259 | 1259 | $give_setting_updated = true; |
1260 | 1260 | |
1261 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1261 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1262 | 1262 | $give_settings['number_decimals'] = 5; |
1263 | 1263 | $give_setting_updated = true; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if ( $give_setting_updated ) { |
|
1267 | - update_option( 'give_settings', $give_settings, false ); |
|
1266 | + if ($give_setting_updated) { |
|
1267 | + update_option('give_settings', $give_settings, false); |
|
1268 | 1268 | } |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1283,69 +1283,69 @@ discard block |
||
1283 | 1283 | $give_updates = Give_Updates::get_instance(); |
1284 | 1284 | |
1285 | 1285 | // form query. |
1286 | - $donation_forms = new WP_Query( array( |
|
1286 | + $donation_forms = new WP_Query(array( |
|
1287 | 1287 | 'paged' => $give_updates->step, |
1288 | 1288 | 'status' => 'any', |
1289 | 1289 | 'order' => 'ASC', |
1290 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1290 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1291 | 1291 | 'posts_per_page' => 20, |
1292 | 1292 | ) |
1293 | 1293 | ); |
1294 | - if ( $donation_forms->have_posts() ) { |
|
1295 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1294 | + if ($donation_forms->have_posts()) { |
|
1295 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1296 | 1296 | |
1297 | - while ( $donation_forms->have_posts() ) { |
|
1297 | + while ($donation_forms->have_posts()) { |
|
1298 | 1298 | $donation_forms->the_post(); |
1299 | 1299 | global $post; |
1300 | 1300 | |
1301 | - $meta = get_post_meta( $post->ID ); |
|
1301 | + $meta = get_post_meta($post->ID); |
|
1302 | 1302 | |
1303 | - switch ( $post->post_type ) { |
|
1303 | + switch ($post->post_type) { |
|
1304 | 1304 | case 'give_forms': |
1305 | 1305 | // _give_set_price. |
1306 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1307 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1306 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1307 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | // _give_custom_amount_minimum. |
1311 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1312 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1311 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1312 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | // _give_levels_minimum_amount. |
1316 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1317 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1316 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1317 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | // _give_levels_maximum_amount. |
1321 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1322 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1321 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1322 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | // _give_set_goal. |
1326 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1327 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1326 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1327 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | // _give_form_earnings. |
1331 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1332 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1331 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1332 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // _give_custom_amount_minimum. |
1336 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1337 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1336 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1337 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1338 | 1338 | |
1339 | - foreach ( $donation_levels as $index => $level ) { |
|
1340 | - if ( empty( $level['_give_amount'] ) ) { |
|
1339 | + foreach ($donation_levels as $index => $level) { |
|
1340 | + if (empty($level['_give_amount'])) { |
|
1341 | 1341 | continue; |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1344 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | $meta['_give_donation_levels'] = $donation_levels; |
1348 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1348 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | |
@@ -1353,8 +1353,8 @@ discard block |
||
1353 | 1353 | |
1354 | 1354 | case 'give_payment': |
1355 | 1355 | // _give_payment_total. |
1356 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1357 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1356 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1357 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | break; |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | wp_reset_postdata(); |
1366 | 1366 | } else { |
1367 | 1367 | // The Update Ran. |
1368 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1368 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1369 | 1369 | } |
1370 | 1370 | } |
1371 | 1371 | |
@@ -1384,22 +1384,22 @@ discard block |
||
1384 | 1384 | $give_updates = Give_Updates::get_instance(); |
1385 | 1385 | |
1386 | 1386 | // form query. |
1387 | - $donors = Give()->donors->get_donors( array( |
|
1387 | + $donors = Give()->donors->get_donors(array( |
|
1388 | 1388 | 'number' => 20, |
1389 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1389 | + 'offset' => $give_updates->get_offset(20), |
|
1390 | 1390 | ) |
1391 | 1391 | ); |
1392 | 1392 | |
1393 | - if ( ! empty( $donors ) ) { |
|
1394 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1393 | + if ( ! empty($donors)) { |
|
1394 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1395 | 1395 | |
1396 | 1396 | /* @var Object $donor */ |
1397 | - foreach ( $donors as $donor ) { |
|
1398 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1397 | + foreach ($donors as $donor) { |
|
1398 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1399 | 1399 | } |
1400 | 1400 | } else { |
1401 | 1401 | // The Update Ran. |
1402 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1402 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1403 | 1403 | } |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1413,25 +1413,25 @@ discard block |
||
1413 | 1413 | $give_updates = Give_Updates::get_instance(); |
1414 | 1414 | |
1415 | 1415 | // Fetch all the existing donors. |
1416 | - $donors = Give()->donors->get_donors( array( |
|
1416 | + $donors = Give()->donors->get_donors(array( |
|
1417 | 1417 | 'number' => 20, |
1418 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1418 | + 'offset' => $give_updates->get_offset(20), |
|
1419 | 1419 | ) |
1420 | 1420 | ); |
1421 | 1421 | |
1422 | - if ( ! empty( $donors ) ) { |
|
1423 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1422 | + if ( ! empty($donors)) { |
|
1423 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1424 | 1424 | |
1425 | 1425 | /* @var Object $donor */ |
1426 | - foreach ( $donors as $donor ) { |
|
1426 | + foreach ($donors as $donor) { |
|
1427 | 1427 | $user_id = $donor->user_id; |
1428 | 1428 | |
1429 | 1429 | // Proceed, if donor is attached with user. |
1430 | - if ( $user_id ) { |
|
1431 | - $user = get_userdata( $user_id ); |
|
1430 | + if ($user_id) { |
|
1431 | + $user = get_userdata($user_id); |
|
1432 | 1432 | |
1433 | 1433 | // Update user role, if user has subscriber role. |
1434 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1434 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1435 | 1435 | wp_update_user( |
1436 | 1436 | array( |
1437 | 1437 | 'ID' => $user_id, |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | } else { |
1445 | 1445 | // The Update Ran. |
1446 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1446 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1447 | 1447 | } |
1448 | 1448 | } |
1449 | 1449 | |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | */ |
1456 | 1456 | function give_v1813_upgrades() { |
1457 | 1457 | // Update admin setting. |
1458 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1458 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1459 | 1459 | |
1460 | 1460 | // Update Give roles. |
1461 | 1461 | $roles = new Give_Roles(); |
@@ -1473,33 +1473,33 @@ discard block |
||
1473 | 1473 | $give_updates = Give_Updates::get_instance(); |
1474 | 1474 | |
1475 | 1475 | // form query. |
1476 | - $payments = new WP_Query( array( |
|
1476 | + $payments = new WP_Query(array( |
|
1477 | 1477 | 'paged' => $give_updates->step, |
1478 | 1478 | 'status' => 'any', |
1479 | 1479 | 'order' => 'ASC', |
1480 | - 'post_type' => array( 'give_payment' ), |
|
1480 | + 'post_type' => array('give_payment'), |
|
1481 | 1481 | 'posts_per_page' => 100, |
1482 | 1482 | ) |
1483 | 1483 | ); |
1484 | 1484 | |
1485 | - if ( $payments->have_posts() ) { |
|
1486 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1485 | + if ($payments->have_posts()) { |
|
1486 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1487 | 1487 | |
1488 | - while ( $payments->have_posts() ) { |
|
1488 | + while ($payments->have_posts()) { |
|
1489 | 1489 | $payments->the_post(); |
1490 | 1490 | |
1491 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1491 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1492 | 1492 | |
1493 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1493 | + if ('RIAL' === $payment_meta['currency']) { |
|
1494 | 1494 | $payment_meta['currency'] = 'IRR'; |
1495 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1495 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | } else { |
1501 | 1501 | // The Update Ran. |
1502 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1502 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1503 | 1503 | } |
1504 | 1504 | } |
1505 | 1505 | |
@@ -1512,9 +1512,9 @@ discard block |
||
1512 | 1512 | function give_v1817_upgrades() { |
1513 | 1513 | $give_settings = give_get_settings(); |
1514 | 1514 | |
1515 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1515 | + if ('RIAL' === $give_settings['currency']) { |
|
1516 | 1516 | $give_settings['currency'] = 'IRR'; |
1517 | - update_option( 'give_settings', $give_settings, false ); |
|
1517 | + update_option('give_settings', $give_settings, false); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | |
1528 | 1528 | global $wp_roles; |
1529 | 1529 | |
1530 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1530 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1531 | 1531 | return; |
1532 | 1532 | } |
1533 | 1533 | |
@@ -1551,15 +1551,15 @@ discard block |
||
1551 | 1551 | ), |
1552 | 1552 | ); |
1553 | 1553 | |
1554 | - foreach ( $add_caps as $role => $caps ) { |
|
1555 | - foreach ( $caps as $cap ) { |
|
1556 | - $wp_roles->add_cap( $role, $cap ); |
|
1554 | + foreach ($add_caps as $role => $caps) { |
|
1555 | + foreach ($caps as $cap) { |
|
1556 | + $wp_roles->add_cap($role, $cap); |
|
1557 | 1557 | } |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - foreach ( $remove_caps as $role => $caps ) { |
|
1561 | - foreach ( $caps as $cap ) { |
|
1562 | - $wp_roles->remove_cap( $role, $cap ); |
|
1560 | + foreach ($remove_caps as $role => $caps) { |
|
1561 | + foreach ($caps as $cap) { |
|
1562 | + $wp_roles->remove_cap($role, $cap); |
|
1563 | 1563 | } |
1564 | 1564 | } |
1565 | 1565 | |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | $roles->add_roles(); |
1584 | 1584 | $roles->add_caps(); |
1585 | 1585 | |
1586 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1586 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | /** |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | function give_v1818_upgrades() { |
1595 | 1595 | |
1596 | 1596 | // Remove email_access_installed from give_settings. |
1597 | - give_delete_option( 'email_access_installed' ); |
|
1597 | + give_delete_option('email_access_installed'); |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | /** |
@@ -1607,23 +1607,23 @@ discard block |
||
1607 | 1607 | /* @var Give_Updates $give_updates */ |
1608 | 1608 | $give_updates = Give_Updates::get_instance(); |
1609 | 1609 | |
1610 | - $donations = new WP_Query( array( |
|
1610 | + $donations = new WP_Query(array( |
|
1611 | 1611 | 'paged' => $give_updates->step, |
1612 | 1612 | 'status' => 'any', |
1613 | 1613 | 'order' => 'ASC', |
1614 | - 'post_type' => array( 'give_payment' ), |
|
1614 | + 'post_type' => array('give_payment'), |
|
1615 | 1615 | 'posts_per_page' => 100, |
1616 | 1616 | ) |
1617 | 1617 | ); |
1618 | 1618 | |
1619 | - if ( $donations->have_posts() ) { |
|
1620 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1619 | + if ($donations->have_posts()) { |
|
1620 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1621 | 1621 | |
1622 | - while ( $donations->have_posts() ) { |
|
1622 | + while ($donations->have_posts()) { |
|
1623 | 1623 | $donations->the_post(); |
1624 | 1624 | |
1625 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1626 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1625 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1626 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1627 | 1627 | |
1628 | 1628 | // Update Donation meta with price_id set as custom, only if it is: |
1629 | 1629 | // 1. Donation Type = Set Donation. |
@@ -1632,19 +1632,19 @@ discard block |
||
1632 | 1632 | if ( |
1633 | 1633 | $form->ID && |
1634 | 1634 | $form->is_set_type_donation_form() && |
1635 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1636 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1635 | + ('custom' !== $donation_meta['price_id']) && |
|
1636 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1637 | 1637 | ) { |
1638 | 1638 | $donation_meta['price_id'] = 'custom'; |
1639 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1640 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1639 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1640 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1641 | 1641 | } |
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | wp_reset_postdata(); |
1645 | 1645 | } else { |
1646 | 1646 | // Update Ran Successfully. |
1647 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1647 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1648 | 1648 | } |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | |
1663 | 1663 | global $wp_roles; |
1664 | 1664 | |
1665 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1665 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1666 | 1666 | return; |
1667 | 1667 | } |
1668 | 1668 | |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | ), |
1681 | 1681 | ); |
1682 | 1682 | |
1683 | - foreach ( $remove_caps as $role => $caps ) { |
|
1684 | - foreach ( $caps as $cap ) { |
|
1685 | - $wp_roles->remove_cap( $role, $cap ); |
|
1683 | + foreach ($remove_caps as $role => $caps) { |
|
1684 | + foreach ($caps as $cap) { |
|
1685 | + $wp_roles->remove_cap($role, $cap); |
|
1686 | 1686 | } |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | $roles->add_roles(); |
1694 | 1694 | $roles->add_caps(); |
1695 | 1695 | |
1696 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1696 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | /** |
@@ -1707,7 +1707,7 @@ discard block |
||
1707 | 1707 | $give_updates = Give_Updates::get_instance(); |
1708 | 1708 | |
1709 | 1709 | // form query |
1710 | - $forms = new WP_Query( array( |
|
1710 | + $forms = new WP_Query(array( |
|
1711 | 1711 | 'paged' => $give_updates->step, |
1712 | 1712 | 'status' => 'any', |
1713 | 1713 | 'order' => 'ASC', |
@@ -1716,22 +1716,22 @@ discard block |
||
1716 | 1716 | ) |
1717 | 1717 | ); |
1718 | 1718 | |
1719 | - if ( $forms->have_posts() ) { |
|
1720 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1719 | + if ($forms->have_posts()) { |
|
1720 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1721 | 1721 | |
1722 | - while ( $forms->have_posts() ) { |
|
1722 | + while ($forms->have_posts()) { |
|
1723 | 1723 | $forms->the_post(); |
1724 | 1724 | global $post; |
1725 | 1725 | |
1726 | 1726 | // Update offline instruction email notification status. |
1727 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1728 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1727 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1728 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1729 | 1729 | 'enabled', |
1730 | 1730 | 'global', |
1731 | - ) ) |
|
1731 | + )) |
|
1732 | 1732 | ? $offline_instruction_notification_status |
1733 | 1733 | : 'global'; |
1734 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1734 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1735 | 1735 | |
1736 | 1736 | // Update offline instruction email message. |
1737 | 1737 | update_post_meta( |
@@ -1763,7 +1763,7 @@ discard block |
||
1763 | 1763 | wp_reset_postdata(); |
1764 | 1764 | } else { |
1765 | 1765 | // No more forms found, finish up. |
1766 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1766 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1767 | 1767 | } |
1768 | 1768 | } |
1769 | 1769 | |
@@ -1780,7 +1780,7 @@ discard block |
||
1780 | 1780 | $give_updates = Give_Updates::get_instance(); |
1781 | 1781 | |
1782 | 1782 | // form query |
1783 | - $forms = new WP_Query( array( |
|
1783 | + $forms = new WP_Query(array( |
|
1784 | 1784 | 'paged' => $give_updates->step, |
1785 | 1785 | 'status' => 'any', |
1786 | 1786 | 'order' => 'ASC', |
@@ -1789,19 +1789,19 @@ discard block |
||
1789 | 1789 | ) |
1790 | 1790 | ); |
1791 | 1791 | |
1792 | - if ( $forms->have_posts() ) { |
|
1793 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1792 | + if ($forms->have_posts()) { |
|
1793 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1794 | 1794 | |
1795 | - while ( $forms->have_posts() ) { |
|
1795 | + while ($forms->have_posts()) { |
|
1796 | 1796 | $forms->the_post(); |
1797 | 1797 | global $post; |
1798 | 1798 | |
1799 | 1799 | // Split _give_payment_meta meta. |
1800 | 1800 | // @todo Remove _give_payment_meta after releases 2.0 |
1801 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1801 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1802 | 1802 | |
1803 | - if ( ! empty( $payment_meta ) ) { |
|
1804 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1803 | + if ( ! empty($payment_meta)) { |
|
1804 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | $deprecated_meta_keys = array( |
@@ -1810,9 +1810,9 @@ discard block |
||
1810 | 1810 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1811 | 1811 | ); |
1812 | 1812 | |
1813 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1813 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1814 | 1814 | // Do not add new meta key if already exist. |
1815 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1815 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1816 | 1816 | continue; |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1821,25 +1821,25 @@ discard block |
||
1821 | 1821 | array( |
1822 | 1822 | 'post_id' => $post->ID, |
1823 | 1823 | 'meta_key' => $new_meta_key, |
1824 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1824 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1825 | 1825 | ) |
1826 | 1826 | ); |
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | // Bailout |
1830 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1830 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1831 | 1831 | /* @var Give_Donor $donor */ |
1832 | - $donor = new Give_Donor( $donor_id ); |
|
1832 | + $donor = new Give_Donor($donor_id); |
|
1833 | 1833 | |
1834 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1835 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1836 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1837 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1838 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1839 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1834 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1835 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1836 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1837 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1838 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1839 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1840 | 1840 | |
1841 | 1841 | // Save address. |
1842 | - $donor->add_address( 'billing[]', $address ); |
|
1842 | + $donor->add_address('billing[]', $address); |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | 1845 | }// End while(). |
@@ -1850,7 +1850,7 @@ discard block |
||
1850 | 1850 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1851 | 1851 | |
1852 | 1852 | // No more forms found, finish up. |
1853 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1853 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1854 | 1854 | } |
1855 | 1855 | } |
1856 | 1856 | |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | $give_updates = Give_Updates::get_instance(); |
1867 | 1867 | |
1868 | 1868 | // form query |
1869 | - $forms = new WP_Query( array( |
|
1869 | + $forms = new WP_Query(array( |
|
1870 | 1870 | 'paged' => $give_updates->step, |
1871 | 1871 | 'order' => 'DESC', |
1872 | 1872 | 'post_type' => 'give_log', |
@@ -1875,20 +1875,20 @@ discard block |
||
1875 | 1875 | ) |
1876 | 1876 | ); |
1877 | 1877 | |
1878 | - if ( $forms->have_posts() ) { |
|
1879 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1878 | + if ($forms->have_posts()) { |
|
1879 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1880 | 1880 | |
1881 | - while ( $forms->have_posts() ) { |
|
1881 | + while ($forms->have_posts()) { |
|
1882 | 1882 | $forms->the_post(); |
1883 | 1883 | global $post; |
1884 | 1884 | |
1885 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1885 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1886 | 1886 | continue; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1890 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1891 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1889 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1890 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1891 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1892 | 1892 | |
1893 | 1893 | $log_data = array( |
1894 | 1894 | 'ID' => $post->ID, |
@@ -1901,29 +1901,29 @@ discard block |
||
1901 | 1901 | ); |
1902 | 1902 | $log_meta = array(); |
1903 | 1903 | |
1904 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1905 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1906 | - switch ( $meta_key ) { |
|
1904 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1905 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1906 | + switch ($meta_key) { |
|
1907 | 1907 | case '_give_log_payment_id': |
1908 | - $log_data['log_parent'] = current( $meta_value ); |
|
1908 | + $log_data['log_parent'] = current($meta_value); |
|
1909 | 1909 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1910 | 1910 | break; |
1911 | 1911 | |
1912 | 1912 | default: |
1913 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1913 | + $log_meta[$meta_key] = current($meta_value); |
|
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 | } |
1917 | 1917 | |
1918 | - if ( 'api_request' === $term_name ) { |
|
1918 | + if ('api_request' === $term_name) { |
|
1919 | 1919 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1920 | 1920 | } |
1921 | 1921 | |
1922 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1922 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1923 | 1923 | |
1924 | - if ( ! empty( $log_meta ) ) { |
|
1925 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1926 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1924 | + if ( ! empty($log_meta)) { |
|
1925 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1926 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1927 | 1927 | } |
1928 | 1928 | } |
1929 | 1929 | |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | Give()->logs->delete_cache(); |
1966 | 1966 | |
1967 | 1967 | // No more forms found, finish up. |
1968 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1968 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1969 | 1969 | } |
1970 | 1970 | } |
1971 | 1971 | |
@@ -1981,19 +1981,19 @@ discard block |
||
1981 | 1981 | $give_updates = Give_Updates::get_instance(); |
1982 | 1982 | |
1983 | 1983 | // form query |
1984 | - $payments = new WP_Query( array( |
|
1984 | + $payments = new WP_Query(array( |
|
1985 | 1985 | 'paged' => $give_updates->step, |
1986 | 1986 | 'status' => 'any', |
1987 | 1987 | 'order' => 'ASC', |
1988 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1988 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1989 | 1989 | 'posts_per_page' => 100, |
1990 | 1990 | ) |
1991 | 1991 | ); |
1992 | 1992 | |
1993 | - if ( $payments->have_posts() ) { |
|
1994 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1993 | + if ($payments->have_posts()) { |
|
1994 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1995 | 1995 | |
1996 | - while ( $payments->have_posts() ) { |
|
1996 | + while ($payments->have_posts()) { |
|
1997 | 1997 | $payments->the_post(); |
1998 | 1998 | global $post; |
1999 | 1999 | |
@@ -2005,19 +2005,19 @@ discard block |
||
2005 | 2005 | ARRAY_A |
2006 | 2006 | ); |
2007 | 2007 | |
2008 | - if ( ! empty( $meta_data ) ) { |
|
2009 | - foreach ( $meta_data as $index => $data ) { |
|
2008 | + if ( ! empty($meta_data)) { |
|
2009 | + foreach ($meta_data as $index => $data) { |
|
2010 | 2010 | // Check for duplicate meta values. |
2011 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2011 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2012 | 2012 | continue; |
2013 | 2013 | } |
2014 | 2014 | |
2015 | - switch ( $post->post_type ) { |
|
2015 | + switch ($post->post_type) { |
|
2016 | 2016 | case 'give_forms': |
2017 | 2017 | $data['form_id'] = $data['post_id']; |
2018 | - unset( $data['post_id'] ); |
|
2018 | + unset($data['post_id']); |
|
2019 | 2019 | |
2020 | - Give()->form_meta->insert( $data ); |
|
2020 | + Give()->form_meta->insert($data); |
|
2021 | 2021 | // @todo: delete form meta from post meta table after releases 2.0. |
2022 | 2022 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2023 | 2023 | |
@@ -2025,9 +2025,9 @@ discard block |
||
2025 | 2025 | |
2026 | 2026 | case 'give_payment': |
2027 | 2027 | $data['payment_id'] = $data['post_id']; |
2028 | - unset( $data['post_id'] ); |
|
2028 | + unset($data['post_id']); |
|
2029 | 2029 | |
2030 | - Give()->payment_meta->insert( $data ); |
|
2030 | + Give()->payment_meta->insert($data); |
|
2031 | 2031 | |
2032 | 2032 | // @todo: delete donation meta from post meta table after releases 2.0. |
2033 | 2033 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2042,7 +2042,7 @@ discard block |
||
2042 | 2042 | wp_reset_postdata(); |
2043 | 2043 | } else { |
2044 | 2044 | // No more forms found, finish up. |
2045 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2045 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | } |
@@ -2058,44 +2058,44 @@ discard block |
||
2058 | 2058 | /* @var Give_Updates $give_updates */ |
2059 | 2059 | $give_updates = Give_Updates::get_instance(); |
2060 | 2060 | |
2061 | - $donors = Give()->donors->get_donors( array( |
|
2061 | + $donors = Give()->donors->get_donors(array( |
|
2062 | 2062 | 'paged' => $give_updates->step, |
2063 | 2063 | 'number' => 100, |
2064 | - ) ); |
|
2064 | + )); |
|
2065 | 2065 | |
2066 | - if ( $donors ) { |
|
2067 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2066 | + if ($donors) { |
|
2067 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2068 | 2068 | // Loop through Donors |
2069 | - foreach ( $donors as $donor ) { |
|
2069 | + foreach ($donors as $donor) { |
|
2070 | 2070 | |
2071 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2072 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2073 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2071 | + $donor_name = explode(' ', $donor->name, 2); |
|
2072 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2073 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2074 | 2074 | |
2075 | 2075 | // If first name meta of donor is not created, then create it. |
2076 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2077 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2076 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2077 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | // If last name meta of donor is not created, then create it. |
2081 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2082 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2081 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2082 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2083 | 2083 | } |
2084 | 2084 | |
2085 | 2085 | // If Donor is connected with WP User then update user meta. |
2086 | - if ( $donor->user_id ) { |
|
2087 | - if ( isset( $donor_name[0] ) ) { |
|
2088 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2086 | + if ($donor->user_id) { |
|
2087 | + if (isset($donor_name[0])) { |
|
2088 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2089 | 2089 | } |
2090 | - if ( isset( $donor_name[1] ) ) { |
|
2091 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2090 | + if (isset($donor_name[1])) { |
|
2091 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | } |
2095 | 2095 | |
2096 | 2096 | } else { |
2097 | 2097 | // The Update Ran. |
2098 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2098 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | } |
@@ -2124,15 +2124,15 @@ discard block |
||
2124 | 2124 | |
2125 | 2125 | $users = $user_query->get_results(); |
2126 | 2126 | |
2127 | - if ( $users ) { |
|
2128 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2127 | + if ($users) { |
|
2128 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2129 | 2129 | |
2130 | 2130 | // Loop through Donors |
2131 | - foreach ( $users as $user ) { |
|
2131 | + foreach ($users as $user) { |
|
2132 | 2132 | /* @var Give_Donor $donor */ |
2133 | - $donor = new Give_Donor( $user->ID, true ); |
|
2133 | + $donor = new Give_Donor($user->ID, true); |
|
2134 | 2134 | |
2135 | - if ( ! $donor->id ) { |
|
2135 | + if ( ! $donor->id) { |
|
2136 | 2136 | continue; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2148,10 +2148,10 @@ discard block |
||
2148 | 2148 | ) |
2149 | 2149 | ); |
2150 | 2150 | |
2151 | - if ( ! empty( $address ) ) { |
|
2152 | - $address = maybe_unserialize( $address ); |
|
2153 | - $donor->add_address( 'personal', $address ); |
|
2154 | - $donor->add_address( 'billing[]', $address ); |
|
2151 | + if ( ! empty($address)) { |
|
2152 | + $address = maybe_unserialize($address); |
|
2153 | + $donor->add_address('personal', $address); |
|
2154 | + $donor->add_address('billing[]', $address); |
|
2155 | 2155 | |
2156 | 2156 | |
2157 | 2157 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | |
2162 | 2162 | } else { |
2163 | 2163 | // The Update Ran. |
2164 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2164 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2165 | 2165 | } |
2166 | 2166 | |
2167 | 2167 | } |
@@ -2185,15 +2185,15 @@ discard block |
||
2185 | 2185 | ); |
2186 | 2186 | |
2187 | 2187 | // Alter customer table |
2188 | - foreach ( $tables as $old_table => $new_table ) { |
|
2188 | + foreach ($tables as $old_table => $new_table) { |
|
2189 | 2189 | if ( |
2190 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2191 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2190 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2191 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2192 | 2192 | ) { |
2193 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2193 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2194 | 2194 | |
2195 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2196 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2195 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2196 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2197 | 2197 | } |
2198 | 2198 | } |
2199 | 2199 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
2201 | 2201 | $give_updates->percentage = 100; |
2202 | 2202 | |
2203 | 2203 | // No more forms found, finish up. |
2204 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2204 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2205 | 2205 | |
2206 | 2206 | // Re initiate donor classes. |
2207 | 2207 | Give()->donors = new Give_DB_Donors(); |
@@ -2219,19 +2219,19 @@ discard block |
||
2219 | 2219 | function give_v201_create_tables() { |
2220 | 2220 | global $wpdb; |
2221 | 2221 | |
2222 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2222 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2223 | 2223 | Give()->payment_meta->create_table(); |
2224 | 2224 | } |
2225 | 2225 | |
2226 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2226 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2227 | 2227 | Give()->form_meta->create_table(); |
2228 | 2228 | } |
2229 | 2229 | |
2230 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2230 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2231 | 2231 | Give()->logs->log_db->create_table(); |
2232 | 2232 | } |
2233 | 2233 | |
2234 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2234 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2235 | 2235 | Give()->logs->logmeta_db->create_table(); |
2236 | 2236 | } |
2237 | 2237 | } |
@@ -2256,31 +2256,31 @@ discard block |
||
2256 | 2256 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2257 | 2257 | ) |
2258 | 2258 | AND $wpdb->posts.post_type = 'give_payment' |
2259 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2259 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2260 | 2260 | ORDER BY $wpdb->posts.post_date ASC |
2261 | 2261 | LIMIT 100 |
2262 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2262 | + OFFSET ".$give_updates->get_offset(100) |
|
2263 | 2263 | ); |
2264 | 2264 | |
2265 | - if ( ! empty( $payments ) ) { |
|
2266 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2265 | + if ( ! empty($payments)) { |
|
2266 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2267 | 2267 | |
2268 | - foreach ( $payments as $payment_id ) { |
|
2269 | - $post = get_post( $payment_id ); |
|
2270 | - setup_postdata( $post ); |
|
2268 | + foreach ($payments as $payment_id) { |
|
2269 | + $post = get_post($payment_id); |
|
2270 | + setup_postdata($post); |
|
2271 | 2271 | |
2272 | 2272 | // Do not add new meta keys if already refactored. |
2273 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2273 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2274 | 2274 | continue; |
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | |
2278 | 2278 | // Split _give_payment_meta meta. |
2279 | 2279 | // @todo Remove _give_payment_meta after releases 2.0 |
2280 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2280 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2281 | 2281 | |
2282 | - if ( ! empty( $payment_meta ) ) { |
|
2283 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2282 | + if ( ! empty($payment_meta)) { |
|
2283 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | $deprecated_meta_keys = array( |
@@ -2289,9 +2289,9 @@ discard block |
||
2289 | 2289 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2290 | 2290 | ); |
2291 | 2291 | |
2292 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2292 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2293 | 2293 | // Do not add new meta key if already exist. |
2294 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2294 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2295 | 2295 | continue; |
2296 | 2296 | } |
2297 | 2297 | |
@@ -2300,25 +2300,25 @@ discard block |
||
2300 | 2300 | array( |
2301 | 2301 | 'post_id' => $post->ID, |
2302 | 2302 | 'meta_key' => $new_meta_key, |
2303 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2303 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2304 | 2304 | ) |
2305 | 2305 | ); |
2306 | 2306 | } |
2307 | 2307 | |
2308 | 2308 | // Bailout |
2309 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2309 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2310 | 2310 | /* @var Give_Donor $donor */ |
2311 | - $donor = new Give_Donor( $donor_id ); |
|
2311 | + $donor = new Give_Donor($donor_id); |
|
2312 | 2312 | |
2313 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2314 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2315 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2316 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2317 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2318 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2313 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2314 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2315 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2316 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2317 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2318 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2319 | 2319 | |
2320 | 2320 | // Save address. |
2321 | - $donor->add_address( 'billing[]', $address ); |
|
2321 | + $donor->add_address('billing[]', $address); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | }// End while(). |
@@ -2329,7 +2329,7 @@ discard block |
||
2329 | 2329 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2330 | 2330 | |
2331 | 2331 | // No more forms found, finish up. |
2332 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2332 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2333 | 2333 | } |
2334 | 2334 | } |
2335 | 2335 | |
@@ -2349,21 +2349,21 @@ discard block |
||
2349 | 2349 | SELECT ID FROM $wpdb->posts |
2350 | 2350 | WHERE 1=1 |
2351 | 2351 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2352 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2352 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2353 | 2353 | ORDER BY $wpdb->posts.post_date ASC |
2354 | 2354 | LIMIT 100 |
2355 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2355 | + OFFSET ".$give_updates->get_offset(100) |
|
2356 | 2356 | ); |
2357 | 2357 | |
2358 | - if ( ! empty( $payments ) ) { |
|
2359 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
2358 | + if ( ! empty($payments)) { |
|
2359 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
2360 | 2360 | 'give_forms', |
2361 | 2361 | 'give_payment', |
2362 | - ) ), $give_updates->step * 100 ); |
|
2362 | + )), $give_updates->step * 100); |
|
2363 | 2363 | |
2364 | - foreach ( $payments as $payment_id ) { |
|
2365 | - $post = get_post( $payment_id ); |
|
2366 | - setup_postdata( $post ); |
|
2364 | + foreach ($payments as $payment_id) { |
|
2365 | + $post = get_post($payment_id); |
|
2366 | + setup_postdata($post); |
|
2367 | 2367 | |
2368 | 2368 | $meta_data = $wpdb->get_results( |
2369 | 2369 | $wpdb->prepare( |
@@ -2373,19 +2373,19 @@ discard block |
||
2373 | 2373 | ARRAY_A |
2374 | 2374 | ); |
2375 | 2375 | |
2376 | - if ( ! empty( $meta_data ) ) { |
|
2377 | - foreach ( $meta_data as $index => $data ) { |
|
2376 | + if ( ! empty($meta_data)) { |
|
2377 | + foreach ($meta_data as $index => $data) { |
|
2378 | 2378 | // Check for duplicate meta values. |
2379 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2379 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2380 | 2380 | continue; |
2381 | 2381 | } |
2382 | 2382 | |
2383 | - switch ( $post->post_type ) { |
|
2383 | + switch ($post->post_type) { |
|
2384 | 2384 | case 'give_forms': |
2385 | 2385 | $data['form_id'] = $data['post_id']; |
2386 | - unset( $data['post_id'] ); |
|
2386 | + unset($data['post_id']); |
|
2387 | 2387 | |
2388 | - Give()->form_meta->insert( $data ); |
|
2388 | + Give()->form_meta->insert($data); |
|
2389 | 2389 | // @todo: delete form meta from post meta table after releases 2.0. |
2390 | 2390 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2391 | 2391 | |
@@ -2393,9 +2393,9 @@ discard block |
||
2393 | 2393 | |
2394 | 2394 | case 'give_payment': |
2395 | 2395 | $data['payment_id'] = $data['post_id']; |
2396 | - unset( $data['post_id'] ); |
|
2396 | + unset($data['post_id']); |
|
2397 | 2397 | |
2398 | - Give()->payment_meta->insert( $data ); |
|
2398 | + Give()->payment_meta->insert($data); |
|
2399 | 2399 | |
2400 | 2400 | // @todo: delete donation meta from post meta table after releases 2.0. |
2401 | 2401 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2410,7 +2410,7 @@ discard block |
||
2410 | 2410 | wp_reset_postdata(); |
2411 | 2411 | } else { |
2412 | 2412 | // No more forms found, finish up. |
2413 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2413 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2414 | 2414 | } |
2415 | 2415 | |
2416 | 2416 | } |
@@ -2431,26 +2431,26 @@ discard block |
||
2431 | 2431 | SELECT ID FROM $wpdb->posts |
2432 | 2432 | WHERE 1=1 |
2433 | 2433 | AND $wpdb->posts.post_type = 'give_log' |
2434 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2434 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2435 | 2435 | ORDER BY $wpdb->posts.post_date ASC |
2436 | 2436 | LIMIT 100 |
2437 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2437 | + OFFSET ".$give_updates->get_offset(100) |
|
2438 | 2438 | ); |
2439 | 2439 | |
2440 | - if ( ! empty( $logs ) ) { |
|
2441 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2440 | + if ( ! empty($logs)) { |
|
2441 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2442 | 2442 | |
2443 | - foreach ( $logs as $log_id ) { |
|
2444 | - $post = get_post( $log_id ); |
|
2445 | - setup_postdata( $post ); |
|
2443 | + foreach ($logs as $log_id) { |
|
2444 | + $post = get_post($log_id); |
|
2445 | + setup_postdata($post); |
|
2446 | 2446 | |
2447 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2447 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2448 | 2448 | continue; |
2449 | 2449 | } |
2450 | 2450 | |
2451 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2452 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2453 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2451 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2452 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2453 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2454 | 2454 | |
2455 | 2455 | $log_data = array( |
2456 | 2456 | 'ID' => $post->ID, |
@@ -2463,29 +2463,29 @@ discard block |
||
2463 | 2463 | ); |
2464 | 2464 | $log_meta = array(); |
2465 | 2465 | |
2466 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2467 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2468 | - switch ( $meta_key ) { |
|
2466 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2467 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2468 | + switch ($meta_key) { |
|
2469 | 2469 | case '_give_log_payment_id': |
2470 | - $log_data['log_parent'] = current( $meta_value ); |
|
2470 | + $log_data['log_parent'] = current($meta_value); |
|
2471 | 2471 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2472 | 2472 | break; |
2473 | 2473 | |
2474 | 2474 | default: |
2475 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2475 | + $log_meta[$meta_key] = current($meta_value); |
|
2476 | 2476 | } |
2477 | 2477 | } |
2478 | 2478 | } |
2479 | 2479 | |
2480 | - if ( 'api_request' === $term_name ) { |
|
2480 | + if ('api_request' === $term_name) { |
|
2481 | 2481 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2482 | 2482 | } |
2483 | 2483 | |
2484 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2484 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2485 | 2485 | |
2486 | - if ( ! empty( $log_meta ) ) { |
|
2487 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2488 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2486 | + if ( ! empty($log_meta)) { |
|
2487 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2488 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2489 | 2489 | } |
2490 | 2490 | } |
2491 | 2491 | |
@@ -2498,7 +2498,7 @@ discard block |
||
2498 | 2498 | Give()->logs->delete_cache(); |
2499 | 2499 | |
2500 | 2500 | // No more forms found, finish up. |
2501 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2501 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2502 | 2502 | } |
2503 | 2503 | } |
2504 | 2504 | |
@@ -2513,51 +2513,51 @@ discard block |
||
2513 | 2513 | global $wpdb; |
2514 | 2514 | give_v201_create_tables(); |
2515 | 2515 | |
2516 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2517 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2518 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2516 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2517 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2518 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2519 | 2519 | $donor_data = array(); |
2520 | 2520 | |
2521 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2522 | - foreach ( $missing_donors as $donor_id ) { |
|
2521 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2522 | + foreach ($missing_donors as $donor_id) { |
|
2523 | 2523 | $donor_data[] = array( |
2524 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2525 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2524 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2525 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2526 | 2526 | |
2527 | 2527 | ); |
2528 | 2528 | } |
2529 | 2529 | } |
2530 | 2530 | |
2531 | - if ( ! empty( $donor_data ) ) { |
|
2531 | + if ( ! empty($donor_data)) { |
|
2532 | 2532 | $donor_table_name = Give()->donors->table_name; |
2533 | 2533 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2534 | 2534 | |
2535 | 2535 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2536 | 2536 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2537 | 2537 | |
2538 | - foreach ( $donor_data as $donor ) { |
|
2538 | + foreach ($donor_data as $donor) { |
|
2539 | 2539 | $donor['info'][0] = (array) $donor['info'][0]; |
2540 | 2540 | |
2541 | 2541 | // Prevent duplicate meta id issue. |
2542 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2542 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2543 | 2543 | continue; |
2544 | 2544 | } |
2545 | 2545 | |
2546 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2546 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2547 | 2547 | |
2548 | - if ( ! empty( $donor['meta'] ) ) { |
|
2549 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2548 | + if ( ! empty($donor['meta'])) { |
|
2549 | + foreach ($donor['meta'] as $donor_meta) { |
|
2550 | 2550 | $donor_meta = (array) $donor_meta; |
2551 | 2551 | |
2552 | 2552 | // Prevent duplicate meta id issue. |
2553 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2554 | - unset( $donor_meta['meta_id'] ); |
|
2553 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2554 | + unset($donor_meta['meta_id']); |
|
2555 | 2555 | } |
2556 | 2556 | |
2557 | 2557 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2558 | - unset( $donor_meta['customer_id'] ); |
|
2558 | + unset($donor_meta['customer_id']); |
|
2559 | 2559 | |
2560 | - Give()->donor_meta->insert( $donor_meta ); |
|
2560 | + Give()->donor_meta->insert($donor_meta); |
|
2561 | 2561 | } |
2562 | 2562 | } |
2563 | 2563 | |
@@ -2576,35 +2576,35 @@ discard block |
||
2576 | 2576 | ) |
2577 | 2577 | ); |
2578 | 2578 | |
2579 | - $donor = new Give_Donor( $donor_id ); |
|
2579 | + $donor = new Give_Donor($donor_id); |
|
2580 | 2580 | |
2581 | - if ( ! empty( $address ) ) { |
|
2582 | - $address = maybe_unserialize( $address ); |
|
2583 | - $donor->add_address( 'personal', $address ); |
|
2584 | - $donor->add_address( 'billing[]', $address ); |
|
2581 | + if ( ! empty($address)) { |
|
2582 | + $address = maybe_unserialize($address); |
|
2583 | + $donor->add_address('personal', $address); |
|
2584 | + $donor->add_address('billing[]', $address); |
|
2585 | 2585 | } |
2586 | 2586 | |
2587 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2588 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2589 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2587 | + $donor_name = explode(' ', $donor->name, 2); |
|
2588 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2589 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2590 | 2590 | |
2591 | 2591 | // If first name meta of donor is not created, then create it. |
2592 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2593 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2592 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2593 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2594 | 2594 | } |
2595 | 2595 | |
2596 | 2596 | // If last name meta of donor is not created, then create it. |
2597 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2598 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2597 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2598 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | // If Donor is connected with WP User then update user meta. |
2602 | - if ( $donor->user_id ) { |
|
2603 | - if ( isset( $donor_name[0] ) ) { |
|
2604 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2602 | + if ($donor->user_id) { |
|
2603 | + if (isset($donor_name[0])) { |
|
2604 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2605 | 2605 | } |
2606 | - if ( isset( $donor_name[1] ) ) { |
|
2607 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2606 | + if (isset($donor_name[1])) { |
|
2607 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2608 | 2608 | } |
2609 | 2609 | } |
2610 | 2610 | } |
@@ -2615,7 +2615,7 @@ discard block |
||
2615 | 2615 | } |
2616 | 2616 | |
2617 | 2617 | Give_Updates::get_instance()->percentage = 100; |
2618 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2618 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | |
@@ -2628,14 +2628,14 @@ discard block |
||
2628 | 2628 | global $wpdb; |
2629 | 2629 | |
2630 | 2630 | // Do not auto load option. |
2631 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2631 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2632 | 2632 | |
2633 | 2633 | // Remove from cache. |
2634 | 2634 | $all_options = wp_load_alloptions(); |
2635 | 2635 | |
2636 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2637 | - unset( $all_options['give_completed_upgrades'] ); |
|
2638 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2636 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2637 | + unset($all_options['give_completed_upgrades']); |
|
2638 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2639 | 2639 | } |
2640 | 2640 | |
2641 | 2641 | } |
@@ -2646,7 +2646,7 @@ discard block |
||
2646 | 2646 | * |
2647 | 2647 | * @since 2.2.0 |
2648 | 2648 | */ |
2649 | -function give_v220_upgrades(){ |
|
2649 | +function give_v220_upgrades() { |
|
2650 | 2650 | global $wpdb; |
2651 | 2651 | |
2652 | 2652 | /** |
@@ -2699,11 +2699,11 @@ discard block |
||
2699 | 2699 | " |
2700 | 2700 | ); |
2701 | 2701 | |
2702 | - if( ! empty( $option_like ) ) { |
|
2703 | - $options = array_merge( $options, $option_like ); |
|
2702 | + if ( ! empty($option_like)) { |
|
2703 | + $options = array_merge($options, $option_like); |
|
2704 | 2704 | } |
2705 | 2705 | |
2706 | - $options_str = '\'' . implode( "','", $options ) . '\''; |
|
2706 | + $options_str = '\''.implode("','", $options).'\''; |
|
2707 | 2707 | |
2708 | 2708 | $wpdb->query( |
2709 | 2709 | " |
@@ -2724,7 +2724,7 @@ discard block |
||
2724 | 2724 | $give_updates = Give_Updates::get_instance(); |
2725 | 2725 | |
2726 | 2726 | // form query. |
2727 | - $donation_forms = new WP_Query( array( |
|
2727 | + $donation_forms = new WP_Query(array( |
|
2728 | 2728 | 'paged' => $give_updates->step, |
2729 | 2729 | 'status' => 'any', |
2730 | 2730 | 'order' => 'ASC', |
@@ -2733,16 +2733,16 @@ discard block |
||
2733 | 2733 | ) |
2734 | 2734 | ); |
2735 | 2735 | |
2736 | - if ( $donation_forms->have_posts() ) { |
|
2737 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
2736 | + if ($donation_forms->have_posts()) { |
|
2737 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
2738 | 2738 | |
2739 | - while ( $donation_forms->have_posts() ) { |
|
2739 | + while ($donation_forms->have_posts()) { |
|
2740 | 2740 | $donation_forms->the_post(); |
2741 | 2741 | $form_id = get_the_ID(); |
2742 | 2742 | |
2743 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
2744 | - if ( empty( $form_closed_status ) ) { |
|
2745 | - give_set_form_closed_status( $form_id ); |
|
2743 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
2744 | + if (empty($form_closed_status)) { |
|
2745 | + give_set_form_closed_status($form_id); |
|
2746 | 2746 | } |
2747 | 2747 | } |
2748 | 2748 | |
@@ -2752,7 +2752,7 @@ discard block |
||
2752 | 2752 | } else { |
2753 | 2753 | |
2754 | 2754 | // The Update Ran. |
2755 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
2755 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
2756 | 2756 | } |
2757 | 2757 | } |
2758 | 2758 | |
@@ -2771,22 +2771,22 @@ discard block |
||
2771 | 2771 | SELECT DISTINCT payment_id |
2772 | 2772 | FROM {$donation_meta_table} |
2773 | 2773 | LIMIT 20 |
2774 | - OFFSET {$give_updates->get_offset( 20 )} |
|
2774 | + OFFSET {$give_updates->get_offset(20)} |
|
2775 | 2775 | " |
2776 | 2776 | ); |
2777 | 2777 | |
2778 | - if ( ! empty( $donations ) ) { |
|
2779 | - foreach ( $donations as $donation ) { |
|
2780 | - $donation_obj = get_post( $donation ); |
|
2778 | + if ( ! empty($donations)) { |
|
2779 | + foreach ($donations as $donation) { |
|
2780 | + $donation_obj = get_post($donation); |
|
2781 | 2781 | |
2782 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
2783 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
2782 | + if ( ! $donation_obj instanceof WP_Post) { |
|
2783 | + Give()->payment_meta->delete_all_meta($donation); |
|
2784 | 2784 | } |
2785 | 2785 | } |
2786 | 2786 | } else { |
2787 | 2787 | |
2788 | 2788 | // The Update Ran. |
2789 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
2789 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
2790 | 2790 | } |
2791 | 2791 | } |
2792 | 2792 | |
@@ -2797,11 +2797,11 @@ discard block |
||
2797 | 2797 | * |
2798 | 2798 | * @since 2.2.0 |
2799 | 2799 | */ |
2800 | -function give_v220_rename_donation_meta_type_callback(){ |
|
2800 | +function give_v220_rename_donation_meta_type_callback() { |
|
2801 | 2801 | global $wpdb; |
2802 | 2802 | |
2803 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)" ); |
|
2804 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta" ); |
|
2803 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)"); |
|
2804 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta"); |
|
2805 | 2805 | |
2806 | 2806 | give_set_upgrade_complete('v220_rename_donation_meta_type'); |
2807 | 2807 | } |
@@ -2813,10 +2813,10 @@ discard block |
||
2813 | 2813 | */ |
2814 | 2814 | function give_v215_update_donor_user_roles_callback() { |
2815 | 2815 | |
2816 | - $role = get_role( 'give_manager' ); |
|
2817 | - $role->add_cap( 'view_give_payments' ); |
|
2816 | + $role = get_role('give_manager'); |
|
2817 | + $role->add_cap('view_give_payments'); |
|
2818 | 2818 | |
2819 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
2819 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | |
@@ -2828,8 +2828,8 @@ discard block |
||
2828 | 2828 | * |
2829 | 2829 | * @global wpdb $wpdb |
2830 | 2830 | */ |
2831 | -function give_v220_delete_wp_session_data(){ |
|
2831 | +function give_v220_delete_wp_session_data() { |
|
2832 | 2832 | global $wpdb; |
2833 | 2833 | |
2834 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'" ); |
|
2834 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'"); |
|
2835 | 2835 | } |