@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | global $wpdb; |
52 | 52 | |
53 | 53 | // @todo: We leave $wpdb->paymentmeta for backward compatibility, use $wpdb->donationmeta instead. We can remove it after 2.1.3. |
54 | - $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_donationmeta'; |
|
54 | + $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix.'give_donationmeta'; |
|
55 | 55 | $this->version = '1.0'; |
56 | 56 | |
57 | 57 | // Backward compatibility. |
58 | - if ( ! give_has_upgrade_completed( 'v220_rename_donation_meta_type' ) ) { |
|
58 | + if ( ! give_has_upgrade_completed('v220_rename_donation_meta_type')) { |
|
59 | 59 | $this->meta_type = 'payment'; |
60 | - $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta'; |
|
60 | + $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $this->register_table(); |
@@ -90,6 +90,6 @@ discard block |
||
90 | 90 | * @return bool |
91 | 91 | */ |
92 | 92 | protected function is_custom_meta_table_active() { |
93 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
93 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
94 | 94 | } |
95 | 95 | } |
@@ -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 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | 'id' => 'v220_rename_donation_meta_type', |
374 | 374 | 'version' => '2.1.3', |
375 | 375 | 'callback' => 'give_v220_rename_donation_meta_type_callback', |
376 | - 'depend' => array( 'v20_move_metadata_into_new_table' ), |
|
376 | + 'depend' => array('v20_move_metadata_into_new_table'), |
|
377 | 377 | ) |
378 | 378 | ); |
379 | 379 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
390 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Triggers all upgrade functions |
@@ -399,29 +399,29 @@ discard block |
||
399 | 399 | */ |
400 | 400 | function give_trigger_upgrades() { |
401 | 401 | |
402 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
403 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
402 | + if ( ! current_user_can('manage_give_settings')) { |
|
403 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
404 | 404 | 'response' => 403, |
405 | - ) ); |
|
405 | + )); |
|
406 | 406 | } |
407 | 407 | |
408 | - $give_version = get_option( 'give_version' ); |
|
408 | + $give_version = get_option('give_version'); |
|
409 | 409 | |
410 | - if ( ! $give_version ) { |
|
410 | + if ( ! $give_version) { |
|
411 | 411 | // 1.0 is the first version to use this option so we must add it. |
412 | 412 | $give_version = '1.0'; |
413 | - add_option( 'give_version', $give_version, '', false ); |
|
413 | + add_option('give_version', $give_version, '', false); |
|
414 | 414 | } |
415 | 415 | |
416 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
417 | - delete_option( 'give_doing_upgrade' ); |
|
416 | + update_option('give_version', GIVE_VERSION, false); |
|
417 | + delete_option('give_doing_upgrade'); |
|
418 | 418 | |
419 | - if ( DOING_AJAX ) { |
|
420 | - die( 'complete' ); |
|
419 | + if (DOING_AJAX) { |
|
420 | + die('complete'); |
|
421 | 421 | } // End if(). |
422 | 422 | } |
423 | 423 | |
424 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
424 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
425 | 425 | |
426 | 426 | |
427 | 427 | /** |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | |
440 | 440 | // UPDATE DB METAKEYS. |
441 | 441 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
442 | - $query = $wpdb->query( $sql ); |
|
442 | + $query = $wpdb->query($sql); |
|
443 | 443 | |
444 | 444 | $give_updates->percentage = 100; |
445 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
445 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -466,24 +466,24 @@ discard block |
||
466 | 466 | $where .= "AND ( p.post_status = 'abandoned' )"; |
467 | 467 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
468 | 468 | |
469 | - $sql = $select . $join . $where; |
|
470 | - $found_payments = $wpdb->get_col( $sql ); |
|
469 | + $sql = $select.$join.$where; |
|
470 | + $found_payments = $wpdb->get_col($sql); |
|
471 | 471 | |
472 | - foreach ( $found_payments as $payment ) { |
|
472 | + foreach ($found_payments as $payment) { |
|
473 | 473 | |
474 | 474 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
475 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
475 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
476 | 476 | |
477 | 477 | // 1450124863 = 12/10/2015 20:42:25. |
478 | - if ( $modified_time >= 1450124863 ) { |
|
478 | + if ($modified_time >= 1450124863) { |
|
479 | 479 | |
480 | - give_update_payment_status( $payment, 'pending' ); |
|
480 | + give_update_payment_status($payment, 'pending'); |
|
481 | 481 | |
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | $give_updates->percentage = 100; |
486 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
486 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -496,17 +496,17 @@ discard block |
||
496 | 496 | */ |
497 | 497 | function give_v152_cleanup_users() { |
498 | 498 | |
499 | - $give_version = get_option( 'give_version' ); |
|
499 | + $give_version = get_option('give_version'); |
|
500 | 500 | |
501 | - if ( ! $give_version ) { |
|
501 | + if ( ! $give_version) { |
|
502 | 502 | // 1.0 is the first version to use this option so we must add it. |
503 | 503 | $give_version = '1.0'; |
504 | 504 | } |
505 | 505 | |
506 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
506 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
507 | 507 | |
508 | 508 | // v1.5.2 Upgrades |
509 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
509 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
510 | 510 | |
511 | 511 | // Delete all caps with "ss". |
512 | 512 | // Also delete all unused "campaign" roles. |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | ); |
554 | 554 | |
555 | 555 | global $wp_roles; |
556 | - foreach ( $delete_caps as $cap ) { |
|
557 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
558 | - $wp_roles->remove_cap( $role, $cap ); |
|
556 | + foreach ($delete_caps as $cap) { |
|
557 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
558 | + $wp_roles->remove_cap($role, $cap); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
@@ -565,15 +565,15 @@ discard block |
||
565 | 565 | $roles->add_caps(); |
566 | 566 | |
567 | 567 | // The Update Ran. |
568 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
569 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
570 | - delete_option( 'give_doing_upgrade' ); |
|
568 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
569 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
570 | + delete_option('give_doing_upgrade'); |
|
571 | 571 | |
572 | 572 | }// End if(). |
573 | 573 | |
574 | 574 | } |
575 | 575 | |
576 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
576 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
577 | 577 | |
578 | 578 | /** |
579 | 579 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -616,53 +616,53 @@ discard block |
||
616 | 616 | |
617 | 617 | // Get addons license key. |
618 | 618 | $addons = array(); |
619 | - foreach ( $give_options as $key => $value ) { |
|
620 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
621 | - $addons[ $key ] = $value; |
|
619 | + foreach ($give_options as $key => $value) { |
|
620 | + if (false !== strpos($key, '_license_key')) { |
|
621 | + $addons[$key] = $value; |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Bailout: We do not have any addon license data to upgrade. |
626 | - if ( empty( $addons ) ) { |
|
626 | + if (empty($addons)) { |
|
627 | 627 | return false; |
628 | 628 | } |
629 | 629 | |
630 | - foreach ( $addons as $key => $addon_license ) { |
|
630 | + foreach ($addons as $key => $addon_license) { |
|
631 | 631 | |
632 | 632 | // Get addon shortname. |
633 | - $shortname = str_replace( '_license_key', '', $key ); |
|
633 | + $shortname = str_replace('_license_key', '', $key); |
|
634 | 634 | |
635 | 635 | // Addon license option name. |
636 | - $addon_license_option_name = $shortname . '_license_active'; |
|
636 | + $addon_license_option_name = $shortname.'_license_active'; |
|
637 | 637 | |
638 | 638 | // bailout if license is empty. |
639 | - if ( empty( $addon_license ) ) { |
|
640 | - delete_option( $addon_license_option_name ); |
|
639 | + if (empty($addon_license)) { |
|
640 | + delete_option($addon_license_option_name); |
|
641 | 641 | continue; |
642 | 642 | } |
643 | 643 | |
644 | 644 | // Get addon name. |
645 | 645 | $addon_name = array(); |
646 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
647 | - foreach ( $addon_name_parts as $name_part ) { |
|
646 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
647 | + foreach ($addon_name_parts as $name_part) { |
|
648 | 648 | |
649 | 649 | // Fix addon name |
650 | - switch ( $name_part ) { |
|
650 | + switch ($name_part) { |
|
651 | 651 | case 'authorizenet' : |
652 | 652 | $name_part = 'authorize.net'; |
653 | 653 | break; |
654 | 654 | } |
655 | 655 | |
656 | - $addon_name[] = ucfirst( $name_part ); |
|
656 | + $addon_name[] = ucfirst($name_part); |
|
657 | 657 | } |
658 | 658 | |
659 | - $addon_name = implode( ' ', $addon_name ); |
|
659 | + $addon_name = implode(' ', $addon_name); |
|
660 | 660 | |
661 | 661 | // Data to send to the API. |
662 | 662 | $api_params = array( |
663 | 663 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
664 | 664 | 'license' => $addon_license, |
665 | - 'item_name' => urlencode( $addon_name ), |
|
665 | + 'item_name' => urlencode($addon_name), |
|
666 | 666 | 'url' => home_url(), |
667 | 667 | ); |
668 | 668 | |
@@ -677,17 +677,17 @@ discard block |
||
677 | 677 | ); |
678 | 678 | |
679 | 679 | // Make sure there are no errors. |
680 | - if ( is_wp_error( $response ) ) { |
|
681 | - delete_option( $addon_license_option_name ); |
|
680 | + if (is_wp_error($response)) { |
|
681 | + delete_option($addon_license_option_name); |
|
682 | 682 | continue; |
683 | 683 | } |
684 | 684 | |
685 | 685 | // Tell WordPress to look for updates. |
686 | - set_site_transient( 'update_plugins', null ); |
|
686 | + set_site_transient('update_plugins', null); |
|
687 | 687 | |
688 | 688 | // Decode license data. |
689 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
690 | - update_option( $addon_license_option_name, $license_data, false ); |
|
689 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
690 | + update_option($addon_license_option_name, $license_data, false); |
|
691 | 691 | }// End foreach(). |
692 | 692 | } |
693 | 693 | |
@@ -717,9 +717,9 @@ discard block |
||
717 | 717 | ); |
718 | 718 | |
719 | 719 | global $wp_roles; |
720 | - foreach ( $delete_caps as $cap ) { |
|
721 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
722 | - $wp_roles->remove_cap( $role, $cap ); |
|
720 | + foreach ($delete_caps as $cap) { |
|
721 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
722 | + $wp_roles->remove_cap($role, $cap); |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | function give_v18_upgrades_core_setting() { |
754 | 754 | // Core settings which changes from checkbox to radio. |
755 | 755 | $core_setting_names = array_merge( |
756 | - array_keys( give_v18_renamed_core_settings() ), |
|
756 | + array_keys(give_v18_renamed_core_settings()), |
|
757 | 757 | array( |
758 | 758 | 'uninstall_on_delete', |
759 | 759 | 'scripts_footer', |
@@ -765,48 +765,48 @@ discard block |
||
765 | 765 | ); |
766 | 766 | |
767 | 767 | // Bailout: If not any setting define. |
768 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
768 | + if ($give_settings = get_option('give_settings')) { |
|
769 | 769 | |
770 | 770 | $setting_changed = false; |
771 | 771 | |
772 | 772 | // Loop: check each setting field. |
773 | - foreach ( $core_setting_names as $setting_name ) { |
|
773 | + foreach ($core_setting_names as $setting_name) { |
|
774 | 774 | // New setting name. |
775 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
775 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
776 | 776 | |
777 | 777 | // Continue: If setting already set. |
778 | 778 | if ( |
779 | - array_key_exists( $new_setting_name, $give_settings ) |
|
780 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
779 | + array_key_exists($new_setting_name, $give_settings) |
|
780 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
781 | 781 | ) { |
782 | 782 | continue; |
783 | 783 | } |
784 | 784 | |
785 | 785 | // Set checkbox value to radio value. |
786 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
786 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
787 | 787 | |
788 | 788 | // @see https://github.com/WordImpress/Give/issues/1063. |
789 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
789 | + if (false !== strpos($setting_name, 'disable_')) { |
|
790 | 790 | |
791 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
792 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
791 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
792 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
793 | 793 | |
794 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
794 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // Tell bot to update core setting to db. |
798 | - if ( ! $setting_changed ) { |
|
798 | + if ( ! $setting_changed) { |
|
799 | 799 | $setting_changed = true; |
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | 803 | // Update setting only if they changed. |
804 | - if ( $setting_changed ) { |
|
805 | - update_option( 'give_settings', $give_settings, false ); |
|
804 | + if ($setting_changed) { |
|
805 | + update_option('give_settings', $give_settings, false); |
|
806 | 806 | } |
807 | 807 | }// End if(). |
808 | 808 | |
809 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
809 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $give_updates = Give_Updates::get_instance(); |
821 | 821 | |
822 | 822 | // form query |
823 | - $forms = new WP_Query( array( |
|
823 | + $forms = new WP_Query(array( |
|
824 | 824 | 'paged' => $give_updates->step, |
825 | 825 | 'status' => 'any', |
826 | 826 | 'order' => 'ASC', |
@@ -829,41 +829,41 @@ discard block |
||
829 | 829 | ) |
830 | 830 | ); |
831 | 831 | |
832 | - if ( $forms->have_posts() ) { |
|
833 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
832 | + if ($forms->have_posts()) { |
|
833 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
834 | 834 | |
835 | - while ( $forms->have_posts() ) { |
|
835 | + while ($forms->have_posts()) { |
|
836 | 836 | $forms->the_post(); |
837 | 837 | |
838 | 838 | // Form content. |
839 | 839 | // Note in version 1.8 display content setting split into display content and content placement setting. |
840 | 840 | // You can delete _give_content_option in future. |
841 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
842 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
843 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
844 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
841 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
842 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
843 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
844 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
845 | 845 | |
846 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
847 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
846 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
847 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | // "Disable" Guest Donation. Checkbox. |
851 | 851 | // See: https://github.com/WordImpress/Give/issues/1470. |
852 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
853 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
854 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
852 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
853 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
854 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
855 | 855 | |
856 | 856 | // Offline Donations. |
857 | 857 | // See: https://github.com/WordImpress/Give/issues/1579. |
858 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
859 | - if ( 'no' === $offline_donation ) { |
|
858 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
859 | + if ('no' === $offline_donation) { |
|
860 | 860 | $offline_donation_newval = 'global'; |
861 | - } elseif ( 'yes' === $offline_donation ) { |
|
861 | + } elseif ('yes' === $offline_donation) { |
|
862 | 862 | $offline_donation_newval = 'enabled'; |
863 | 863 | } else { |
864 | 864 | $offline_donation_newval = 'disabled'; |
865 | 865 | } |
866 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
866 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
867 | 867 | |
868 | 868 | // Convert yes/no setting field to enabled/disabled. |
869 | 869 | $form_radio_settings = array( |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | '_give_offline_donation_enable_billing_fields_single', |
884 | 884 | ); |
885 | 885 | |
886 | - foreach ( $form_radio_settings as $meta_key ) { |
|
886 | + foreach ($form_radio_settings as $meta_key) { |
|
887 | 887 | // Get value. |
888 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
888 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
889 | 889 | |
890 | 890 | // Convert meta value only if it is in yes/no/none. |
891 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
891 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
892 | 892 | |
893 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
894 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
893 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
894 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | }// End while(). |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | |
901 | 901 | } else { |
902 | 902 | // No more forms found, finish up. |
903 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
903 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | '%_transient_give_stats_%', |
968 | 968 | 'give_cache%', |
969 | 969 | '%_transient_give_add_ons_feed%', |
970 | - '%_transient__give_ajax_works' . |
|
970 | + '%_transient__give_ajax_works'. |
|
971 | 971 | '%_transient_give_total_api_keys%', |
972 | 972 | '%_transient_give_i18n_give_promo_hide%', |
973 | 973 | '%_transient_give_contributors%', |
@@ -994,24 +994,24 @@ discard block |
||
994 | 994 | ARRAY_A |
995 | 995 | ); |
996 | 996 | |
997 | - if ( ! empty( $user_apikey_options ) ) { |
|
998 | - foreach ( $user_apikey_options as $user ) { |
|
999 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
1000 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
1001 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
997 | + if ( ! empty($user_apikey_options)) { |
|
998 | + foreach ($user_apikey_options as $user) { |
|
999 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
1000 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
1001 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
1002 | 1002 | } |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - if ( ! empty( $cached_options ) ) { |
|
1006 | - foreach ( $cached_options as $option ) { |
|
1007 | - switch ( true ) { |
|
1008 | - case ( false !== strpos( $option, 'transient' ) ): |
|
1009 | - $option = str_replace( '_transient_', '', $option ); |
|
1010 | - delete_transient( $option ); |
|
1005 | + if ( ! empty($cached_options)) { |
|
1006 | + foreach ($cached_options as $option) { |
|
1007 | + switch (true) { |
|
1008 | + case (false !== strpos($option, 'transient')): |
|
1009 | + $option = str_replace('_transient_', '', $option); |
|
1010 | + delete_transient($option); |
|
1011 | 1011 | break; |
1012 | 1012 | |
1013 | 1013 | default: |
1014 | - delete_option( $option ); |
|
1014 | + delete_option($option); |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | global $wp_roles; |
1030 | 1030 | |
1031 | 1031 | // Get the role object. |
1032 | - $give_worker = get_role( 'give_worker' ); |
|
1032 | + $give_worker = get_role('give_worker'); |
|
1033 | 1033 | |
1034 | 1034 | // A list of capabilities to add for give workers. |
1035 | 1035 | $caps_to_add = array( |
@@ -1037,9 +1037,9 @@ discard block |
||
1037 | 1037 | 'edit_pages', |
1038 | 1038 | ); |
1039 | 1039 | |
1040 | - foreach ( $caps_to_add as $cap ) { |
|
1040 | + foreach ($caps_to_add as $cap) { |
|
1041 | 1041 | // Add the capability. |
1042 | - $give_worker->add_cap( $cap ); |
|
1042 | + $give_worker->add_cap($cap); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | } |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | $give_updates = Give_Updates::get_instance(); |
1057 | 1057 | |
1058 | 1058 | // form query. |
1059 | - $donation_forms = new WP_Query( array( |
|
1059 | + $donation_forms = new WP_Query(array( |
|
1060 | 1060 | 'paged' => $give_updates->step, |
1061 | 1061 | 'status' => 'any', |
1062 | 1062 | 'order' => 'ASC', |
@@ -1065,10 +1065,10 @@ discard block |
||
1065 | 1065 | ) |
1066 | 1066 | ); |
1067 | 1067 | |
1068 | - if ( $donation_forms->have_posts() ) { |
|
1069 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1068 | + if ($donation_forms->have_posts()) { |
|
1069 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1070 | 1070 | |
1071 | - while ( $donation_forms->have_posts() ) { |
|
1071 | + while ($donation_forms->have_posts()) { |
|
1072 | 1072 | $donation_forms->the_post(); |
1073 | 1073 | $form_id = get_the_ID(); |
1074 | 1074 | |
@@ -1076,41 +1076,41 @@ discard block |
||
1076 | 1076 | update_post_meta( |
1077 | 1077 | $form_id, |
1078 | 1078 | '_give_set_price', |
1079 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1079 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1080 | 1080 | ); |
1081 | 1081 | |
1082 | 1082 | // Remove formatting from _give_custom_amount_minimum. |
1083 | 1083 | update_post_meta( |
1084 | 1084 | $form_id, |
1085 | 1085 | '_give_custom_amount_minimum', |
1086 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1086 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1087 | 1087 | ); |
1088 | 1088 | |
1089 | 1089 | // Bailout. |
1090 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1090 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1091 | 1091 | continue; |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1094 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1095 | 1095 | |
1096 | - if ( ! empty( $donation_levels ) ) { |
|
1096 | + if ( ! empty($donation_levels)) { |
|
1097 | 1097 | |
1098 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1099 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1100 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1098 | + foreach ($donation_levels as $index => $donation_level) { |
|
1099 | + if (isset($donation_level['_give_amount'])) { |
|
1100 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1104 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1105 | 1105 | |
1106 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1106 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1107 | 1107 | |
1108 | - $min_amount = min( $donation_levels_amounts ); |
|
1109 | - $max_amount = max( $donation_levels_amounts ); |
|
1108 | + $min_amount = min($donation_levels_amounts); |
|
1109 | + $max_amount = max($donation_levels_amounts); |
|
1110 | 1110 | |
1111 | 1111 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1112 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1113 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1112 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1113 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | wp_reset_postdata(); |
1120 | 1120 | } else { |
1121 | 1121 | // The Update Ran. |
1122 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1122 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | */ |
1170 | 1170 | function give_v20_upgrades() { |
1171 | 1171 | // Update cache setting. |
1172 | - give_update_option( 'cache', 'enabled' ); |
|
1172 | + give_update_option('cache', 'enabled'); |
|
1173 | 1173 | |
1174 | 1174 | // Upgrade email settings. |
1175 | 1175 | give_v20_upgrades_email_setting(); |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | $all_setting = give_get_settings(); |
1189 | 1189 | |
1190 | 1190 | // Bailout on fresh install. |
1191 | - if ( empty( $all_setting ) ) { |
|
1191 | + if (empty($all_setting)) { |
|
1192 | 1192 | return; |
1193 | 1193 | } |
1194 | 1194 | |
@@ -1207,19 +1207,19 @@ discard block |
||
1207 | 1207 | 'admin_notices' => 'new-donation_notification', |
1208 | 1208 | ); |
1209 | 1209 | |
1210 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1210 | + foreach ($settings as $old_setting => $new_setting) { |
|
1211 | 1211 | // Do not update already modified |
1212 | - if ( ! is_array( $new_setting ) ) { |
|
1213 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1212 | + if ( ! is_array($new_setting)) { |
|
1213 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1214 | 1214 | continue; |
1215 | 1215 | } |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - switch ( $old_setting ) { |
|
1218 | + switch ($old_setting) { |
|
1219 | 1219 | case 'admin_notices': |
1220 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1220 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1221 | 1221 | |
1222 | - give_update_option( $new_setting, $notification_status ); |
|
1222 | + give_update_option($new_setting, $notification_status); |
|
1223 | 1223 | |
1224 | 1224 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1225 | 1225 | // give_delete_option( $old_setting ); |
@@ -1230,19 +1230,19 @@ discard block |
||
1230 | 1230 | case 'admin_notice_emails': |
1231 | 1231 | $recipients = give_get_admin_notice_emails(); |
1232 | 1232 | |
1233 | - foreach ( $new_setting as $setting ) { |
|
1233 | + foreach ($new_setting as $setting) { |
|
1234 | 1234 | // bailout if setting already exist. |
1235 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1235 | + if (array_key_exists($setting, $all_setting)) { |
|
1236 | 1236 | continue; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - give_update_option( $setting, $recipients ); |
|
1239 | + give_update_option($setting, $recipients); |
|
1240 | 1240 | } |
1241 | 1241 | break; |
1242 | 1242 | |
1243 | 1243 | default: |
1244 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1245 | - give_delete_option( $old_setting ); |
|
1244 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1245 | + give_delete_option($old_setting); |
|
1246 | 1246 | } |
1247 | 1247 | } |
1248 | 1248 | } |
@@ -1259,22 +1259,22 @@ discard block |
||
1259 | 1259 | $give_settings = give_get_settings(); |
1260 | 1260 | $give_setting_updated = false; |
1261 | 1261 | |
1262 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1262 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1263 | 1263 | $give_settings['number_decimals'] = 0; |
1264 | 1264 | $give_settings['decimal_separator'] = ''; |
1265 | 1265 | $give_setting_updated = true; |
1266 | 1266 | |
1267 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1267 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1268 | 1268 | $give_settings['number_decimals'] = 0; |
1269 | 1269 | $give_setting_updated = true; |
1270 | 1270 | |
1271 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1271 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1272 | 1272 | $give_settings['number_decimals'] = 5; |
1273 | 1273 | $give_setting_updated = true; |
1274 | 1274 | } |
1275 | 1275 | |
1276 | - if ( $give_setting_updated ) { |
|
1277 | - update_option( 'give_settings', $give_settings, false ); |
|
1276 | + if ($give_setting_updated) { |
|
1277 | + update_option('give_settings', $give_settings, false); |
|
1278 | 1278 | } |
1279 | 1279 | } |
1280 | 1280 | |
@@ -1293,69 +1293,69 @@ discard block |
||
1293 | 1293 | $give_updates = Give_Updates::get_instance(); |
1294 | 1294 | |
1295 | 1295 | // form query. |
1296 | - $donation_forms = new WP_Query( array( |
|
1296 | + $donation_forms = new WP_Query(array( |
|
1297 | 1297 | 'paged' => $give_updates->step, |
1298 | 1298 | 'status' => 'any', |
1299 | 1299 | 'order' => 'ASC', |
1300 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1300 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1301 | 1301 | 'posts_per_page' => 20, |
1302 | 1302 | ) |
1303 | 1303 | ); |
1304 | - if ( $donation_forms->have_posts() ) { |
|
1305 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1304 | + if ($donation_forms->have_posts()) { |
|
1305 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1306 | 1306 | |
1307 | - while ( $donation_forms->have_posts() ) { |
|
1307 | + while ($donation_forms->have_posts()) { |
|
1308 | 1308 | $donation_forms->the_post(); |
1309 | 1309 | global $post; |
1310 | 1310 | |
1311 | - $meta = get_post_meta( $post->ID ); |
|
1311 | + $meta = get_post_meta($post->ID); |
|
1312 | 1312 | |
1313 | - switch ( $post->post_type ) { |
|
1313 | + switch ($post->post_type) { |
|
1314 | 1314 | case 'give_forms': |
1315 | 1315 | // _give_set_price. |
1316 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1317 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1316 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1317 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | // _give_custom_amount_minimum. |
1321 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1322 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1321 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1322 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | // _give_levels_minimum_amount. |
1326 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1327 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1326 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1327 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | // _give_levels_maximum_amount. |
1331 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1332 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1331 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1332 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // _give_set_goal. |
1336 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1337 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1336 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1337 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | // _give_form_earnings. |
1341 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1342 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1341 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1342 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | // _give_custom_amount_minimum. |
1346 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1347 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1346 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1347 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1348 | 1348 | |
1349 | - foreach ( $donation_levels as $index => $level ) { |
|
1350 | - if ( empty( $level['_give_amount'] ) ) { |
|
1349 | + foreach ($donation_levels as $index => $level) { |
|
1350 | + if (empty($level['_give_amount'])) { |
|
1351 | 1351 | continue; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1354 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | $meta['_give_donation_levels'] = $donation_levels; |
1358 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1358 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | |
1364 | 1364 | case 'give_payment': |
1365 | 1365 | // _give_payment_total. |
1366 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1367 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1366 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1367 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | break; |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | wp_reset_postdata(); |
1376 | 1376 | } else { |
1377 | 1377 | // The Update Ran. |
1378 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1378 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1394,22 +1394,22 @@ discard block |
||
1394 | 1394 | $give_updates = Give_Updates::get_instance(); |
1395 | 1395 | |
1396 | 1396 | // form query. |
1397 | - $donors = Give()->donors->get_donors( array( |
|
1397 | + $donors = Give()->donors->get_donors(array( |
|
1398 | 1398 | 'number' => 20, |
1399 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1399 | + 'offset' => $give_updates->get_offset(20), |
|
1400 | 1400 | ) |
1401 | 1401 | ); |
1402 | 1402 | |
1403 | - if ( ! empty( $donors ) ) { |
|
1404 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1403 | + if ( ! empty($donors)) { |
|
1404 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1405 | 1405 | |
1406 | 1406 | /* @var Object $donor */ |
1407 | - foreach ( $donors as $donor ) { |
|
1408 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1407 | + foreach ($donors as $donor) { |
|
1408 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1409 | 1409 | } |
1410 | 1410 | } else { |
1411 | 1411 | // The Update Ran. |
1412 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1412 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1413 | 1413 | } |
1414 | 1414 | } |
1415 | 1415 | |
@@ -1423,25 +1423,25 @@ discard block |
||
1423 | 1423 | $give_updates = Give_Updates::get_instance(); |
1424 | 1424 | |
1425 | 1425 | // Fetch all the existing donors. |
1426 | - $donors = Give()->donors->get_donors( array( |
|
1426 | + $donors = Give()->donors->get_donors(array( |
|
1427 | 1427 | 'number' => 20, |
1428 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1428 | + 'offset' => $give_updates->get_offset(20), |
|
1429 | 1429 | ) |
1430 | 1430 | ); |
1431 | 1431 | |
1432 | - if ( ! empty( $donors ) ) { |
|
1433 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1432 | + if ( ! empty($donors)) { |
|
1433 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1434 | 1434 | |
1435 | 1435 | /* @var Object $donor */ |
1436 | - foreach ( $donors as $donor ) { |
|
1436 | + foreach ($donors as $donor) { |
|
1437 | 1437 | $user_id = $donor->user_id; |
1438 | 1438 | |
1439 | 1439 | // Proceed, if donor is attached with user. |
1440 | - if ( $user_id ) { |
|
1441 | - $user = get_userdata( $user_id ); |
|
1440 | + if ($user_id) { |
|
1441 | + $user = get_userdata($user_id); |
|
1442 | 1442 | |
1443 | 1443 | // Update user role, if user has subscriber role. |
1444 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1444 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1445 | 1445 | wp_update_user( |
1446 | 1446 | array( |
1447 | 1447 | 'ID' => $user_id, |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | } |
1454 | 1454 | } else { |
1455 | 1455 | // The Update Ran. |
1456 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1456 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1457 | 1457 | } |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1465,7 +1465,7 @@ discard block |
||
1465 | 1465 | */ |
1466 | 1466 | function give_v1813_upgrades() { |
1467 | 1467 | // Update admin setting. |
1468 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1468 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1469 | 1469 | |
1470 | 1470 | // Update Give roles. |
1471 | 1471 | $roles = new Give_Roles(); |
@@ -1483,33 +1483,33 @@ discard block |
||
1483 | 1483 | $give_updates = Give_Updates::get_instance(); |
1484 | 1484 | |
1485 | 1485 | // form query. |
1486 | - $payments = new WP_Query( array( |
|
1486 | + $payments = new WP_Query(array( |
|
1487 | 1487 | 'paged' => $give_updates->step, |
1488 | 1488 | 'status' => 'any', |
1489 | 1489 | 'order' => 'ASC', |
1490 | - 'post_type' => array( 'give_payment' ), |
|
1490 | + 'post_type' => array('give_payment'), |
|
1491 | 1491 | 'posts_per_page' => 100, |
1492 | 1492 | ) |
1493 | 1493 | ); |
1494 | 1494 | |
1495 | - if ( $payments->have_posts() ) { |
|
1496 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1495 | + if ($payments->have_posts()) { |
|
1496 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1497 | 1497 | |
1498 | - while ( $payments->have_posts() ) { |
|
1498 | + while ($payments->have_posts()) { |
|
1499 | 1499 | $payments->the_post(); |
1500 | 1500 | |
1501 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1501 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1502 | 1502 | |
1503 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1503 | + if ('RIAL' === $payment_meta['currency']) { |
|
1504 | 1504 | $payment_meta['currency'] = 'IRR'; |
1505 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1505 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | } |
1509 | 1509 | |
1510 | 1510 | } else { |
1511 | 1511 | // The Update Ran. |
1512 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1512 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1513 | 1513 | } |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1522,9 +1522,9 @@ discard block |
||
1522 | 1522 | function give_v1817_upgrades() { |
1523 | 1523 | $give_settings = give_get_settings(); |
1524 | 1524 | |
1525 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1525 | + if ('RIAL' === $give_settings['currency']) { |
|
1526 | 1526 | $give_settings['currency'] = 'IRR'; |
1527 | - update_option( 'give_settings', $give_settings, false ); |
|
1527 | + update_option('give_settings', $give_settings, false); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | |
1538 | 1538 | global $wp_roles; |
1539 | 1539 | |
1540 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1540 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1541 | 1541 | return; |
1542 | 1542 | } |
1543 | 1543 | |
@@ -1561,15 +1561,15 @@ discard block |
||
1561 | 1561 | ), |
1562 | 1562 | ); |
1563 | 1563 | |
1564 | - foreach ( $add_caps as $role => $caps ) { |
|
1565 | - foreach ( $caps as $cap ) { |
|
1566 | - $wp_roles->add_cap( $role, $cap ); |
|
1564 | + foreach ($add_caps as $role => $caps) { |
|
1565 | + foreach ($caps as $cap) { |
|
1566 | + $wp_roles->add_cap($role, $cap); |
|
1567 | 1567 | } |
1568 | 1568 | } |
1569 | 1569 | |
1570 | - foreach ( $remove_caps as $role => $caps ) { |
|
1571 | - foreach ( $caps as $cap ) { |
|
1572 | - $wp_roles->remove_cap( $role, $cap ); |
|
1570 | + foreach ($remove_caps as $role => $caps) { |
|
1571 | + foreach ($caps as $cap) { |
|
1572 | + $wp_roles->remove_cap($role, $cap); |
|
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 | |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $roles->add_roles(); |
1594 | 1594 | $roles->add_caps(); |
1595 | 1595 | |
1596 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1596 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | /** |
@@ -1604,7 +1604,7 @@ discard block |
||
1604 | 1604 | function give_v1818_upgrades() { |
1605 | 1605 | |
1606 | 1606 | // Remove email_access_installed from give_settings. |
1607 | - give_delete_option( 'email_access_installed' ); |
|
1607 | + give_delete_option('email_access_installed'); |
|
1608 | 1608 | } |
1609 | 1609 | |
1610 | 1610 | /** |
@@ -1617,23 +1617,23 @@ discard block |
||
1617 | 1617 | /* @var Give_Updates $give_updates */ |
1618 | 1618 | $give_updates = Give_Updates::get_instance(); |
1619 | 1619 | |
1620 | - $donations = new WP_Query( array( |
|
1620 | + $donations = new WP_Query(array( |
|
1621 | 1621 | 'paged' => $give_updates->step, |
1622 | 1622 | 'status' => 'any', |
1623 | 1623 | 'order' => 'ASC', |
1624 | - 'post_type' => array( 'give_payment' ), |
|
1624 | + 'post_type' => array('give_payment'), |
|
1625 | 1625 | 'posts_per_page' => 100, |
1626 | 1626 | ) |
1627 | 1627 | ); |
1628 | 1628 | |
1629 | - if ( $donations->have_posts() ) { |
|
1630 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1629 | + if ($donations->have_posts()) { |
|
1630 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1631 | 1631 | |
1632 | - while ( $donations->have_posts() ) { |
|
1632 | + while ($donations->have_posts()) { |
|
1633 | 1633 | $donations->the_post(); |
1634 | 1634 | |
1635 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1636 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1635 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1636 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1637 | 1637 | |
1638 | 1638 | // Update Donation meta with price_id set as custom, only if it is: |
1639 | 1639 | // 1. Donation Type = Set Donation. |
@@ -1642,19 +1642,19 @@ discard block |
||
1642 | 1642 | if ( |
1643 | 1643 | $form->ID && |
1644 | 1644 | $form->is_set_type_donation_form() && |
1645 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1646 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1645 | + ('custom' !== $donation_meta['price_id']) && |
|
1646 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1647 | 1647 | ) { |
1648 | 1648 | $donation_meta['price_id'] = 'custom'; |
1649 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1650 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1649 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1650 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 | |
1654 | 1654 | wp_reset_postdata(); |
1655 | 1655 | } else { |
1656 | 1656 | // Update Ran Successfully. |
1657 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1657 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1658 | 1658 | } |
1659 | 1659 | } |
1660 | 1660 | |
@@ -1672,7 +1672,7 @@ discard block |
||
1672 | 1672 | |
1673 | 1673 | global $wp_roles; |
1674 | 1674 | |
1675 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1675 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1676 | 1676 | return; |
1677 | 1677 | } |
1678 | 1678 | |
@@ -1690,9 +1690,9 @@ discard block |
||
1690 | 1690 | ), |
1691 | 1691 | ); |
1692 | 1692 | |
1693 | - foreach ( $remove_caps as $role => $caps ) { |
|
1694 | - foreach ( $caps as $cap ) { |
|
1695 | - $wp_roles->remove_cap( $role, $cap ); |
|
1693 | + foreach ($remove_caps as $role => $caps) { |
|
1694 | + foreach ($caps as $cap) { |
|
1695 | + $wp_roles->remove_cap($role, $cap); |
|
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | $roles->add_roles(); |
1704 | 1704 | $roles->add_caps(); |
1705 | 1705 | |
1706 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1706 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | 1709 | /** |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | $give_updates = Give_Updates::get_instance(); |
1718 | 1718 | |
1719 | 1719 | // form query |
1720 | - $forms = new WP_Query( array( |
|
1720 | + $forms = new WP_Query(array( |
|
1721 | 1721 | 'paged' => $give_updates->step, |
1722 | 1722 | 'status' => 'any', |
1723 | 1723 | 'order' => 'ASC', |
@@ -1726,22 +1726,22 @@ discard block |
||
1726 | 1726 | ) |
1727 | 1727 | ); |
1728 | 1728 | |
1729 | - if ( $forms->have_posts() ) { |
|
1730 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1729 | + if ($forms->have_posts()) { |
|
1730 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1731 | 1731 | |
1732 | - while ( $forms->have_posts() ) { |
|
1732 | + while ($forms->have_posts()) { |
|
1733 | 1733 | $forms->the_post(); |
1734 | 1734 | global $post; |
1735 | 1735 | |
1736 | 1736 | // Update offline instruction email notification status. |
1737 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1738 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1737 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1738 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1739 | 1739 | 'enabled', |
1740 | 1740 | 'global', |
1741 | - ) ) |
|
1741 | + )) |
|
1742 | 1742 | ? $offline_instruction_notification_status |
1743 | 1743 | : 'global'; |
1744 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1744 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1745 | 1745 | |
1746 | 1746 | // Update offline instruction email message. |
1747 | 1747 | update_post_meta( |
@@ -1773,7 +1773,7 @@ discard block |
||
1773 | 1773 | wp_reset_postdata(); |
1774 | 1774 | } else { |
1775 | 1775 | // No more forms found, finish up. |
1776 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1776 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1777 | 1777 | } |
1778 | 1778 | } |
1779 | 1779 | |
@@ -1790,7 +1790,7 @@ discard block |
||
1790 | 1790 | $give_updates = Give_Updates::get_instance(); |
1791 | 1791 | |
1792 | 1792 | // form query |
1793 | - $forms = new WP_Query( array( |
|
1793 | + $forms = new WP_Query(array( |
|
1794 | 1794 | 'paged' => $give_updates->step, |
1795 | 1795 | 'status' => 'any', |
1796 | 1796 | 'order' => 'ASC', |
@@ -1799,19 +1799,19 @@ discard block |
||
1799 | 1799 | ) |
1800 | 1800 | ); |
1801 | 1801 | |
1802 | - if ( $forms->have_posts() ) { |
|
1803 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1802 | + if ($forms->have_posts()) { |
|
1803 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1804 | 1804 | |
1805 | - while ( $forms->have_posts() ) { |
|
1805 | + while ($forms->have_posts()) { |
|
1806 | 1806 | $forms->the_post(); |
1807 | 1807 | global $post; |
1808 | 1808 | |
1809 | 1809 | // Split _give_payment_meta meta. |
1810 | 1810 | // @todo Remove _give_payment_meta after releases 2.0 |
1811 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1811 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1812 | 1812 | |
1813 | - if ( ! empty( $payment_meta ) ) { |
|
1814 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1813 | + if ( ! empty($payment_meta)) { |
|
1814 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1815 | 1815 | } |
1816 | 1816 | |
1817 | 1817 | $deprecated_meta_keys = array( |
@@ -1820,9 +1820,9 @@ discard block |
||
1820 | 1820 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1821 | 1821 | ); |
1822 | 1822 | |
1823 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1823 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1824 | 1824 | // Do not add new meta key if already exist. |
1825 | - 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 ) ) ) { |
|
1825 | + 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))) { |
|
1826 | 1826 | continue; |
1827 | 1827 | } |
1828 | 1828 | |
@@ -1831,25 +1831,25 @@ discard block |
||
1831 | 1831 | array( |
1832 | 1832 | 'post_id' => $post->ID, |
1833 | 1833 | 'meta_key' => $new_meta_key, |
1834 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1834 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1835 | 1835 | ) |
1836 | 1836 | ); |
1837 | 1837 | } |
1838 | 1838 | |
1839 | 1839 | // Bailout |
1840 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1840 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1841 | 1841 | /* @var Give_Donor $donor */ |
1842 | - $donor = new Give_Donor( $donor_id ); |
|
1842 | + $donor = new Give_Donor($donor_id); |
|
1843 | 1843 | |
1844 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1845 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1846 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1847 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1848 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1849 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1844 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1845 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1846 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1847 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1848 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1849 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1850 | 1850 | |
1851 | 1851 | // Save address. |
1852 | - $donor->add_address( 'billing[]', $address ); |
|
1852 | + $donor->add_address('billing[]', $address); |
|
1853 | 1853 | } |
1854 | 1854 | |
1855 | 1855 | }// End while(). |
@@ -1860,7 +1860,7 @@ discard block |
||
1860 | 1860 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1861 | 1861 | |
1862 | 1862 | // No more forms found, finish up. |
1863 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1863 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1864 | 1864 | } |
1865 | 1865 | } |
1866 | 1866 | |
@@ -1876,7 +1876,7 @@ discard block |
||
1876 | 1876 | $give_updates = Give_Updates::get_instance(); |
1877 | 1877 | |
1878 | 1878 | // form query |
1879 | - $forms = new WP_Query( array( |
|
1879 | + $forms = new WP_Query(array( |
|
1880 | 1880 | 'paged' => $give_updates->step, |
1881 | 1881 | 'order' => 'DESC', |
1882 | 1882 | 'post_type' => 'give_log', |
@@ -1885,20 +1885,20 @@ discard block |
||
1885 | 1885 | ) |
1886 | 1886 | ); |
1887 | 1887 | |
1888 | - if ( $forms->have_posts() ) { |
|
1889 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1888 | + if ($forms->have_posts()) { |
|
1889 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1890 | 1890 | |
1891 | - while ( $forms->have_posts() ) { |
|
1891 | + while ($forms->have_posts()) { |
|
1892 | 1892 | $forms->the_post(); |
1893 | 1893 | global $post; |
1894 | 1894 | |
1895 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1895 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1896 | 1896 | continue; |
1897 | 1897 | } |
1898 | 1898 | |
1899 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1900 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1901 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1899 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1900 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1901 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1902 | 1902 | |
1903 | 1903 | $log_data = array( |
1904 | 1904 | 'ID' => $post->ID, |
@@ -1911,29 +1911,29 @@ discard block |
||
1911 | 1911 | ); |
1912 | 1912 | $log_meta = array(); |
1913 | 1913 | |
1914 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1915 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1916 | - switch ( $meta_key ) { |
|
1914 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1915 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1916 | + switch ($meta_key) { |
|
1917 | 1917 | case '_give_log_payment_id': |
1918 | - $log_data['log_parent'] = current( $meta_value ); |
|
1918 | + $log_data['log_parent'] = current($meta_value); |
|
1919 | 1919 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1920 | 1920 | break; |
1921 | 1921 | |
1922 | 1922 | default: |
1923 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1923 | + $log_meta[$meta_key] = current($meta_value); |
|
1924 | 1924 | } |
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | |
1928 | - if ( 'api_request' === $term_name ) { |
|
1928 | + if ('api_request' === $term_name) { |
|
1929 | 1929 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1930 | 1930 | } |
1931 | 1931 | |
1932 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1932 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1933 | 1933 | |
1934 | - if ( ! empty( $log_meta ) ) { |
|
1935 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1936 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1934 | + if ( ! empty($log_meta)) { |
|
1935 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1936 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1937 | 1937 | } |
1938 | 1938 | } |
1939 | 1939 | |
@@ -1975,7 +1975,7 @@ discard block |
||
1975 | 1975 | Give()->logs->delete_cache(); |
1976 | 1976 | |
1977 | 1977 | // No more forms found, finish up. |
1978 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1978 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1979 | 1979 | } |
1980 | 1980 | } |
1981 | 1981 | |
@@ -1991,19 +1991,19 @@ discard block |
||
1991 | 1991 | $give_updates = Give_Updates::get_instance(); |
1992 | 1992 | |
1993 | 1993 | // form query |
1994 | - $payments = new WP_Query( array( |
|
1994 | + $payments = new WP_Query(array( |
|
1995 | 1995 | 'paged' => $give_updates->step, |
1996 | 1996 | 'status' => 'any', |
1997 | 1997 | 'order' => 'ASC', |
1998 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1998 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1999 | 1999 | 'posts_per_page' => 100, |
2000 | 2000 | ) |
2001 | 2001 | ); |
2002 | 2002 | |
2003 | - if ( $payments->have_posts() ) { |
|
2004 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
2003 | + if ($payments->have_posts()) { |
|
2004 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
2005 | 2005 | |
2006 | - while ( $payments->have_posts() ) { |
|
2006 | + while ($payments->have_posts()) { |
|
2007 | 2007 | $payments->the_post(); |
2008 | 2008 | global $post; |
2009 | 2009 | |
@@ -2015,19 +2015,19 @@ discard block |
||
2015 | 2015 | ARRAY_A |
2016 | 2016 | ); |
2017 | 2017 | |
2018 | - if ( ! empty( $meta_data ) ) { |
|
2019 | - foreach ( $meta_data as $index => $data ) { |
|
2018 | + if ( ! empty($meta_data)) { |
|
2019 | + foreach ($meta_data as $index => $data) { |
|
2020 | 2020 | // Check for duplicate meta values. |
2021 | - 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 ) ) { |
|
2021 | + 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)) { |
|
2022 | 2022 | continue; |
2023 | 2023 | } |
2024 | 2024 | |
2025 | - switch ( $post->post_type ) { |
|
2025 | + switch ($post->post_type) { |
|
2026 | 2026 | case 'give_forms': |
2027 | 2027 | $data['form_id'] = $data['post_id']; |
2028 | - unset( $data['post_id'] ); |
|
2028 | + unset($data['post_id']); |
|
2029 | 2029 | |
2030 | - Give()->form_meta->insert( $data ); |
|
2030 | + Give()->form_meta->insert($data); |
|
2031 | 2031 | // @todo: delete form meta from post meta table after releases 2.0. |
2032 | 2032 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2033 | 2033 | |
@@ -2035,9 +2035,9 @@ discard block |
||
2035 | 2035 | |
2036 | 2036 | case 'give_payment': |
2037 | 2037 | $data['payment_id'] = $data['post_id']; |
2038 | - unset( $data['post_id'] ); |
|
2038 | + unset($data['post_id']); |
|
2039 | 2039 | |
2040 | - Give()->payment_meta->insert( $data ); |
|
2040 | + Give()->payment_meta->insert($data); |
|
2041 | 2041 | |
2042 | 2042 | // @todo: delete donation meta from post meta table after releases 2.0. |
2043 | 2043 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2052,7 +2052,7 @@ discard block |
||
2052 | 2052 | wp_reset_postdata(); |
2053 | 2053 | } else { |
2054 | 2054 | // No more forms found, finish up. |
2055 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2055 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2056 | 2056 | } |
2057 | 2057 | |
2058 | 2058 | } |
@@ -2068,44 +2068,44 @@ discard block |
||
2068 | 2068 | /* @var Give_Updates $give_updates */ |
2069 | 2069 | $give_updates = Give_Updates::get_instance(); |
2070 | 2070 | |
2071 | - $donors = Give()->donors->get_donors( array( |
|
2071 | + $donors = Give()->donors->get_donors(array( |
|
2072 | 2072 | 'paged' => $give_updates->step, |
2073 | 2073 | 'number' => 100, |
2074 | - ) ); |
|
2074 | + )); |
|
2075 | 2075 | |
2076 | - if ( $donors ) { |
|
2077 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2076 | + if ($donors) { |
|
2077 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2078 | 2078 | // Loop through Donors |
2079 | - foreach ( $donors as $donor ) { |
|
2079 | + foreach ($donors as $donor) { |
|
2080 | 2080 | |
2081 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2082 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2083 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2081 | + $donor_name = explode(' ', $donor->name, 2); |
|
2082 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2083 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2084 | 2084 | |
2085 | 2085 | // If first name meta of donor is not created, then create it. |
2086 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2087 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2086 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2087 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2088 | 2088 | } |
2089 | 2089 | |
2090 | 2090 | // If last name meta of donor is not created, then create it. |
2091 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2092 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2091 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2092 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | // If Donor is connected with WP User then update user meta. |
2096 | - if ( $donor->user_id ) { |
|
2097 | - if ( isset( $donor_name[0] ) ) { |
|
2098 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2096 | + if ($donor->user_id) { |
|
2097 | + if (isset($donor_name[0])) { |
|
2098 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2099 | 2099 | } |
2100 | - if ( isset( $donor_name[1] ) ) { |
|
2101 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2100 | + if (isset($donor_name[1])) { |
|
2101 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2102 | 2102 | } |
2103 | 2103 | } |
2104 | 2104 | } |
2105 | 2105 | |
2106 | 2106 | } else { |
2107 | 2107 | // The Update Ran. |
2108 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2108 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2109 | 2109 | } |
2110 | 2110 | |
2111 | 2111 | } |
@@ -2134,15 +2134,15 @@ discard block |
||
2134 | 2134 | |
2135 | 2135 | $users = $user_query->get_results(); |
2136 | 2136 | |
2137 | - if ( $users ) { |
|
2138 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2137 | + if ($users) { |
|
2138 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2139 | 2139 | |
2140 | 2140 | // Loop through Donors |
2141 | - foreach ( $users as $user ) { |
|
2141 | + foreach ($users as $user) { |
|
2142 | 2142 | /* @var Give_Donor $donor */ |
2143 | - $donor = new Give_Donor( $user->ID, true ); |
|
2143 | + $donor = new Give_Donor($user->ID, true); |
|
2144 | 2144 | |
2145 | - if ( ! $donor->id ) { |
|
2145 | + if ( ! $donor->id) { |
|
2146 | 2146 | continue; |
2147 | 2147 | } |
2148 | 2148 | |
@@ -2158,10 +2158,10 @@ discard block |
||
2158 | 2158 | ) |
2159 | 2159 | ); |
2160 | 2160 | |
2161 | - if ( ! empty( $address ) ) { |
|
2162 | - $address = maybe_unserialize( $address ); |
|
2163 | - $donor->add_address( 'personal', $address ); |
|
2164 | - $donor->add_address( 'billing[]', $address ); |
|
2161 | + if ( ! empty($address)) { |
|
2162 | + $address = maybe_unserialize($address); |
|
2163 | + $donor->add_address('personal', $address); |
|
2164 | + $donor->add_address('billing[]', $address); |
|
2165 | 2165 | |
2166 | 2166 | |
2167 | 2167 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2171,7 +2171,7 @@ discard block |
||
2171 | 2171 | |
2172 | 2172 | } else { |
2173 | 2173 | // The Update Ran. |
2174 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2174 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2175 | 2175 | } |
2176 | 2176 | |
2177 | 2177 | } |
@@ -2195,15 +2195,15 @@ discard block |
||
2195 | 2195 | ); |
2196 | 2196 | |
2197 | 2197 | // Alter customer table |
2198 | - foreach ( $tables as $old_table => $new_table ) { |
|
2198 | + foreach ($tables as $old_table => $new_table) { |
|
2199 | 2199 | if ( |
2200 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2201 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2200 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2201 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2202 | 2202 | ) { |
2203 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2203 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2204 | 2204 | |
2205 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2206 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2205 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2206 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2207 | 2207 | } |
2208 | 2208 | } |
2209 | 2209 | } |
@@ -2211,7 +2211,7 @@ discard block |
||
2211 | 2211 | $give_updates->percentage = 100; |
2212 | 2212 | |
2213 | 2213 | // No more forms found, finish up. |
2214 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2214 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2215 | 2215 | |
2216 | 2216 | // Re initiate donor classes. |
2217 | 2217 | Give()->donors = new Give_DB_Donors(); |
@@ -2229,19 +2229,19 @@ discard block |
||
2229 | 2229 | function give_v201_create_tables() { |
2230 | 2230 | global $wpdb; |
2231 | 2231 | |
2232 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2232 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2233 | 2233 | Give()->payment_meta->create_table(); |
2234 | 2234 | } |
2235 | 2235 | |
2236 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2236 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2237 | 2237 | Give()->form_meta->create_table(); |
2238 | 2238 | } |
2239 | 2239 | |
2240 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2240 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2241 | 2241 | Give()->logs->log_db->create_table(); |
2242 | 2242 | } |
2243 | 2243 | |
2244 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2244 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2245 | 2245 | Give()->logs->logmeta_db->create_table(); |
2246 | 2246 | } |
2247 | 2247 | } |
@@ -2266,31 +2266,31 @@ discard block |
||
2266 | 2266 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2267 | 2267 | ) |
2268 | 2268 | AND $wpdb->posts.post_type = 'give_payment' |
2269 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2269 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2270 | 2270 | ORDER BY $wpdb->posts.post_date ASC |
2271 | 2271 | LIMIT 100 |
2272 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2272 | + OFFSET ".$give_updates->get_offset(100) |
|
2273 | 2273 | ); |
2274 | 2274 | |
2275 | - if ( ! empty( $payments ) ) { |
|
2276 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2275 | + if ( ! empty($payments)) { |
|
2276 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2277 | 2277 | |
2278 | - foreach ( $payments as $payment_id ) { |
|
2279 | - $post = get_post( $payment_id ); |
|
2280 | - setup_postdata( $post ); |
|
2278 | + foreach ($payments as $payment_id) { |
|
2279 | + $post = get_post($payment_id); |
|
2280 | + setup_postdata($post); |
|
2281 | 2281 | |
2282 | 2282 | // Do not add new meta keys if already refactored. |
2283 | - 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' ) ) ) { |
|
2283 | + 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'))) { |
|
2284 | 2284 | continue; |
2285 | 2285 | } |
2286 | 2286 | |
2287 | 2287 | |
2288 | 2288 | // Split _give_payment_meta meta. |
2289 | 2289 | // @todo Remove _give_payment_meta after releases 2.0 |
2290 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2290 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2291 | 2291 | |
2292 | - if ( ! empty( $payment_meta ) ) { |
|
2293 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2292 | + if ( ! empty($payment_meta)) { |
|
2293 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2294 | 2294 | } |
2295 | 2295 | |
2296 | 2296 | $deprecated_meta_keys = array( |
@@ -2299,9 +2299,9 @@ discard block |
||
2299 | 2299 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2300 | 2300 | ); |
2301 | 2301 | |
2302 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2302 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2303 | 2303 | // Do not add new meta key if already exist. |
2304 | - 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 ) ) ) { |
|
2304 | + 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))) { |
|
2305 | 2305 | continue; |
2306 | 2306 | } |
2307 | 2307 | |
@@ -2310,25 +2310,25 @@ discard block |
||
2310 | 2310 | array( |
2311 | 2311 | 'post_id' => $post->ID, |
2312 | 2312 | 'meta_key' => $new_meta_key, |
2313 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2313 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2314 | 2314 | ) |
2315 | 2315 | ); |
2316 | 2316 | } |
2317 | 2317 | |
2318 | 2318 | // Bailout |
2319 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2319 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2320 | 2320 | /* @var Give_Donor $donor */ |
2321 | - $donor = new Give_Donor( $donor_id ); |
|
2321 | + $donor = new Give_Donor($donor_id); |
|
2322 | 2322 | |
2323 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2324 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2325 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2326 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2327 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2328 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2323 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2324 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2325 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2326 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2327 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2328 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2329 | 2329 | |
2330 | 2330 | // Save address. |
2331 | - $donor->add_address( 'billing[]', $address ); |
|
2331 | + $donor->add_address('billing[]', $address); |
|
2332 | 2332 | } |
2333 | 2333 | |
2334 | 2334 | }// End while(). |
@@ -2339,7 +2339,7 @@ discard block |
||
2339 | 2339 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2340 | 2340 | |
2341 | 2341 | // No more forms found, finish up. |
2342 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2342 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2343 | 2343 | } |
2344 | 2344 | } |
2345 | 2345 | |
@@ -2359,21 +2359,21 @@ discard block |
||
2359 | 2359 | SELECT ID FROM $wpdb->posts |
2360 | 2360 | WHERE 1=1 |
2361 | 2361 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2362 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2362 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2363 | 2363 | ORDER BY $wpdb->posts.post_date ASC |
2364 | 2364 | LIMIT 100 |
2365 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2365 | + OFFSET ".$give_updates->get_offset(100) |
|
2366 | 2366 | ); |
2367 | 2367 | |
2368 | - if ( ! empty( $payments ) ) { |
|
2369 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
2368 | + if ( ! empty($payments)) { |
|
2369 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
2370 | 2370 | 'give_forms', |
2371 | 2371 | 'give_payment', |
2372 | - ) ), $give_updates->step * 100 ); |
|
2372 | + )), $give_updates->step * 100); |
|
2373 | 2373 | |
2374 | - foreach ( $payments as $payment_id ) { |
|
2375 | - $post = get_post( $payment_id ); |
|
2376 | - setup_postdata( $post ); |
|
2374 | + foreach ($payments as $payment_id) { |
|
2375 | + $post = get_post($payment_id); |
|
2376 | + setup_postdata($post); |
|
2377 | 2377 | |
2378 | 2378 | $meta_data = $wpdb->get_results( |
2379 | 2379 | $wpdb->prepare( |
@@ -2383,19 +2383,19 @@ discard block |
||
2383 | 2383 | ARRAY_A |
2384 | 2384 | ); |
2385 | 2385 | |
2386 | - if ( ! empty( $meta_data ) ) { |
|
2387 | - foreach ( $meta_data as $index => $data ) { |
|
2386 | + if ( ! empty($meta_data)) { |
|
2387 | + foreach ($meta_data as $index => $data) { |
|
2388 | 2388 | // Check for duplicate meta values. |
2389 | - 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 ) ) { |
|
2389 | + 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)) { |
|
2390 | 2390 | continue; |
2391 | 2391 | } |
2392 | 2392 | |
2393 | - switch ( $post->post_type ) { |
|
2393 | + switch ($post->post_type) { |
|
2394 | 2394 | case 'give_forms': |
2395 | 2395 | $data['form_id'] = $data['post_id']; |
2396 | - unset( $data['post_id'] ); |
|
2396 | + unset($data['post_id']); |
|
2397 | 2397 | |
2398 | - Give()->form_meta->insert( $data ); |
|
2398 | + Give()->form_meta->insert($data); |
|
2399 | 2399 | // @todo: delete form meta from post meta table after releases 2.0. |
2400 | 2400 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2401 | 2401 | |
@@ -2403,9 +2403,9 @@ discard block |
||
2403 | 2403 | |
2404 | 2404 | case 'give_payment': |
2405 | 2405 | $data['payment_id'] = $data['post_id']; |
2406 | - unset( $data['post_id'] ); |
|
2406 | + unset($data['post_id']); |
|
2407 | 2407 | |
2408 | - Give()->payment_meta->insert( $data ); |
|
2408 | + Give()->payment_meta->insert($data); |
|
2409 | 2409 | |
2410 | 2410 | // @todo: delete donation meta from post meta table after releases 2.0. |
2411 | 2411 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2420,7 +2420,7 @@ discard block |
||
2420 | 2420 | wp_reset_postdata(); |
2421 | 2421 | } else { |
2422 | 2422 | // No more forms found, finish up. |
2423 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2423 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2424 | 2424 | } |
2425 | 2425 | |
2426 | 2426 | } |
@@ -2441,26 +2441,26 @@ discard block |
||
2441 | 2441 | SELECT ID FROM $wpdb->posts |
2442 | 2442 | WHERE 1=1 |
2443 | 2443 | AND $wpdb->posts.post_type = 'give_log' |
2444 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2444 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2445 | 2445 | ORDER BY $wpdb->posts.post_date ASC |
2446 | 2446 | LIMIT 100 |
2447 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2447 | + OFFSET ".$give_updates->get_offset(100) |
|
2448 | 2448 | ); |
2449 | 2449 | |
2450 | - if ( ! empty( $logs ) ) { |
|
2451 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2450 | + if ( ! empty($logs)) { |
|
2451 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2452 | 2452 | |
2453 | - foreach ( $logs as $log_id ) { |
|
2454 | - $post = get_post( $log_id ); |
|
2455 | - setup_postdata( $post ); |
|
2453 | + foreach ($logs as $log_id) { |
|
2454 | + $post = get_post($log_id); |
|
2455 | + setup_postdata($post); |
|
2456 | 2456 | |
2457 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2457 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2458 | 2458 | continue; |
2459 | 2459 | } |
2460 | 2460 | |
2461 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2462 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2463 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2461 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2462 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2463 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2464 | 2464 | |
2465 | 2465 | $log_data = array( |
2466 | 2466 | 'ID' => $post->ID, |
@@ -2473,29 +2473,29 @@ discard block |
||
2473 | 2473 | ); |
2474 | 2474 | $log_meta = array(); |
2475 | 2475 | |
2476 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2477 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2478 | - switch ( $meta_key ) { |
|
2476 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2477 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2478 | + switch ($meta_key) { |
|
2479 | 2479 | case '_give_log_payment_id': |
2480 | - $log_data['log_parent'] = current( $meta_value ); |
|
2480 | + $log_data['log_parent'] = current($meta_value); |
|
2481 | 2481 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2482 | 2482 | break; |
2483 | 2483 | |
2484 | 2484 | default: |
2485 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2485 | + $log_meta[$meta_key] = current($meta_value); |
|
2486 | 2486 | } |
2487 | 2487 | } |
2488 | 2488 | } |
2489 | 2489 | |
2490 | - if ( 'api_request' === $term_name ) { |
|
2490 | + if ('api_request' === $term_name) { |
|
2491 | 2491 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2492 | 2492 | } |
2493 | 2493 | |
2494 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2494 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2495 | 2495 | |
2496 | - if ( ! empty( $log_meta ) ) { |
|
2497 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2498 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2496 | + if ( ! empty($log_meta)) { |
|
2497 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2498 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2499 | 2499 | } |
2500 | 2500 | } |
2501 | 2501 | |
@@ -2508,7 +2508,7 @@ discard block |
||
2508 | 2508 | Give()->logs->delete_cache(); |
2509 | 2509 | |
2510 | 2510 | // No more forms found, finish up. |
2511 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2511 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2512 | 2512 | } |
2513 | 2513 | } |
2514 | 2514 | |
@@ -2523,51 +2523,51 @@ discard block |
||
2523 | 2523 | global $wpdb; |
2524 | 2524 | give_v201_create_tables(); |
2525 | 2525 | |
2526 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2527 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2528 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2526 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2527 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2528 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2529 | 2529 | $donor_data = array(); |
2530 | 2530 | |
2531 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2532 | - foreach ( $missing_donors as $donor_id ) { |
|
2531 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2532 | + foreach ($missing_donors as $donor_id) { |
|
2533 | 2533 | $donor_data[] = array( |
2534 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2535 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2534 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2535 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2536 | 2536 | |
2537 | 2537 | ); |
2538 | 2538 | } |
2539 | 2539 | } |
2540 | 2540 | |
2541 | - if ( ! empty( $donor_data ) ) { |
|
2541 | + if ( ! empty($donor_data)) { |
|
2542 | 2542 | $donor_table_name = Give()->donors->table_name; |
2543 | 2543 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2544 | 2544 | |
2545 | 2545 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2546 | 2546 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2547 | 2547 | |
2548 | - foreach ( $donor_data as $donor ) { |
|
2548 | + foreach ($donor_data as $donor) { |
|
2549 | 2549 | $donor['info'][0] = (array) $donor['info'][0]; |
2550 | 2550 | |
2551 | 2551 | // Prevent duplicate meta id issue. |
2552 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2552 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2553 | 2553 | continue; |
2554 | 2554 | } |
2555 | 2555 | |
2556 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2556 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2557 | 2557 | |
2558 | - if ( ! empty( $donor['meta'] ) ) { |
|
2559 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2558 | + if ( ! empty($donor['meta'])) { |
|
2559 | + foreach ($donor['meta'] as $donor_meta) { |
|
2560 | 2560 | $donor_meta = (array) $donor_meta; |
2561 | 2561 | |
2562 | 2562 | // Prevent duplicate meta id issue. |
2563 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2564 | - unset( $donor_meta['meta_id'] ); |
|
2563 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2564 | + unset($donor_meta['meta_id']); |
|
2565 | 2565 | } |
2566 | 2566 | |
2567 | 2567 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2568 | - unset( $donor_meta['customer_id'] ); |
|
2568 | + unset($donor_meta['customer_id']); |
|
2569 | 2569 | |
2570 | - Give()->donor_meta->insert( $donor_meta ); |
|
2570 | + Give()->donor_meta->insert($donor_meta); |
|
2571 | 2571 | } |
2572 | 2572 | } |
2573 | 2573 | |
@@ -2586,35 +2586,35 @@ discard block |
||
2586 | 2586 | ) |
2587 | 2587 | ); |
2588 | 2588 | |
2589 | - $donor = new Give_Donor( $donor_id ); |
|
2589 | + $donor = new Give_Donor($donor_id); |
|
2590 | 2590 | |
2591 | - if ( ! empty( $address ) ) { |
|
2592 | - $address = maybe_unserialize( $address ); |
|
2593 | - $donor->add_address( 'personal', $address ); |
|
2594 | - $donor->add_address( 'billing[]', $address ); |
|
2591 | + if ( ! empty($address)) { |
|
2592 | + $address = maybe_unserialize($address); |
|
2593 | + $donor->add_address('personal', $address); |
|
2594 | + $donor->add_address('billing[]', $address); |
|
2595 | 2595 | } |
2596 | 2596 | |
2597 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2598 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2599 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2597 | + $donor_name = explode(' ', $donor->name, 2); |
|
2598 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2599 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2600 | 2600 | |
2601 | 2601 | // If first name meta of donor is not created, then create it. |
2602 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2603 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2602 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2603 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2604 | 2604 | } |
2605 | 2605 | |
2606 | 2606 | // If last name meta of donor is not created, then create it. |
2607 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2608 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2607 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2608 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2609 | 2609 | } |
2610 | 2610 | |
2611 | 2611 | // If Donor is connected with WP User then update user meta. |
2612 | - if ( $donor->user_id ) { |
|
2613 | - if ( isset( $donor_name[0] ) ) { |
|
2614 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2612 | + if ($donor->user_id) { |
|
2613 | + if (isset($donor_name[0])) { |
|
2614 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2615 | 2615 | } |
2616 | - if ( isset( $donor_name[1] ) ) { |
|
2617 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2616 | + if (isset($donor_name[1])) { |
|
2617 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2618 | 2618 | } |
2619 | 2619 | } |
2620 | 2620 | } |
@@ -2625,7 +2625,7 @@ discard block |
||
2625 | 2625 | } |
2626 | 2626 | |
2627 | 2627 | Give_Updates::get_instance()->percentage = 100; |
2628 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2628 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2629 | 2629 | } |
2630 | 2630 | |
2631 | 2631 | |
@@ -2638,14 +2638,14 @@ discard block |
||
2638 | 2638 | global $wpdb; |
2639 | 2639 | |
2640 | 2640 | // Do not auto load option. |
2641 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2641 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2642 | 2642 | |
2643 | 2643 | // Remove from cache. |
2644 | 2644 | $all_options = wp_load_alloptions(); |
2645 | 2645 | |
2646 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2647 | - unset( $all_options['give_completed_upgrades'] ); |
|
2648 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2646 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2647 | + unset($all_options['give_completed_upgrades']); |
|
2648 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2649 | 2649 | } |
2650 | 2650 | |
2651 | 2651 | } |
@@ -2656,7 +2656,7 @@ discard block |
||
2656 | 2656 | * |
2657 | 2657 | * @since 2.2.0 |
2658 | 2658 | */ |
2659 | -function give_v220_upgrades(){ |
|
2659 | +function give_v220_upgrades() { |
|
2660 | 2660 | global $wpdb; |
2661 | 2661 | |
2662 | 2662 | /** |
@@ -2702,11 +2702,11 @@ discard block |
||
2702 | 2702 | " |
2703 | 2703 | ); |
2704 | 2704 | |
2705 | - if( ! empty( $option_like ) ) { |
|
2706 | - $options = array_merge( $options, $option_like ); |
|
2705 | + if ( ! empty($option_like)) { |
|
2706 | + $options = array_merge($options, $option_like); |
|
2707 | 2707 | } |
2708 | 2708 | |
2709 | - $options_str = '\'' . implode( "','", $options ) . '\''; |
|
2709 | + $options_str = '\''.implode("','", $options).'\''; |
|
2710 | 2710 | |
2711 | 2711 | $wpdb->query( |
2712 | 2712 | " |
@@ -2727,7 +2727,7 @@ discard block |
||
2727 | 2727 | $give_updates = Give_Updates::get_instance(); |
2728 | 2728 | |
2729 | 2729 | // form query. |
2730 | - $donation_forms = new WP_Query( array( |
|
2730 | + $donation_forms = new WP_Query(array( |
|
2731 | 2731 | 'paged' => $give_updates->step, |
2732 | 2732 | 'status' => 'any', |
2733 | 2733 | 'order' => 'ASC', |
@@ -2736,16 +2736,16 @@ discard block |
||
2736 | 2736 | ) |
2737 | 2737 | ); |
2738 | 2738 | |
2739 | - if ( $donation_forms->have_posts() ) { |
|
2740 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
2739 | + if ($donation_forms->have_posts()) { |
|
2740 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
2741 | 2741 | |
2742 | - while ( $donation_forms->have_posts() ) { |
|
2742 | + while ($donation_forms->have_posts()) { |
|
2743 | 2743 | $donation_forms->the_post(); |
2744 | 2744 | $form_id = get_the_ID(); |
2745 | 2745 | |
2746 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
2747 | - if ( empty( $form_closed_status ) ) { |
|
2748 | - give_set_form_closed_status( $form_id ); |
|
2746 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
2747 | + if (empty($form_closed_status)) { |
|
2748 | + give_set_form_closed_status($form_id); |
|
2749 | 2749 | } |
2750 | 2750 | } |
2751 | 2751 | |
@@ -2755,7 +2755,7 @@ discard block |
||
2755 | 2755 | } else { |
2756 | 2756 | |
2757 | 2757 | // The Update Ran. |
2758 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
2758 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
2759 | 2759 | } |
2760 | 2760 | } |
2761 | 2761 | |
@@ -2774,22 +2774,22 @@ discard block |
||
2774 | 2774 | SELECT DISTINCT payment_id |
2775 | 2775 | FROM {$donation_meta_table} |
2776 | 2776 | LIMIT 20 |
2777 | - OFFSET {$give_updates->get_offset( 20 )} |
|
2777 | + OFFSET {$give_updates->get_offset(20)} |
|
2778 | 2778 | " |
2779 | 2779 | ); |
2780 | 2780 | |
2781 | - if ( ! empty( $donations ) ) { |
|
2782 | - foreach ( $donations as $donation ) { |
|
2783 | - $donation_obj = get_post( $donation ); |
|
2781 | + if ( ! empty($donations)) { |
|
2782 | + foreach ($donations as $donation) { |
|
2783 | + $donation_obj = get_post($donation); |
|
2784 | 2784 | |
2785 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
2786 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
2785 | + if ( ! $donation_obj instanceof WP_Post) { |
|
2786 | + Give()->payment_meta->delete_all_meta($donation); |
|
2787 | 2787 | } |
2788 | 2788 | } |
2789 | 2789 | } else { |
2790 | 2790 | |
2791 | 2791 | // The Update Ran. |
2792 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
2792 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
2793 | 2793 | } |
2794 | 2794 | } |
2795 | 2795 | |
@@ -2800,12 +2800,12 @@ discard block |
||
2800 | 2800 | * |
2801 | 2801 | * @since 2.2.0 |
2802 | 2802 | */ |
2803 | -function give_v220_rename_donation_meta_type_callback(){ |
|
2803 | +function give_v220_rename_donation_meta_type_callback() { |
|
2804 | 2804 | global $wpdb; |
2805 | 2805 | $give_updates = Give_Updates::get_instance(); |
2806 | 2806 | |
2807 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)" ); |
|
2808 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta" ); |
|
2807 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)"); |
|
2808 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta"); |
|
2809 | 2809 | |
2810 | 2810 | give_set_upgrade_complete('v220_rename_donation_meta_type'); |
2811 | 2811 | $give_updates->set_percentage(1, 1); |
@@ -2818,10 +2818,10 @@ discard block |
||
2818 | 2818 | */ |
2819 | 2819 | function give_v215_update_donor_user_roles_callback() { |
2820 | 2820 | |
2821 | - $role = get_role( 'give_manager' ); |
|
2822 | - $role->add_cap( 'view_give_payments' ); |
|
2821 | + $role = get_role('give_manager'); |
|
2822 | + $role->add_cap('view_give_payments'); |
|
2823 | 2823 | |
2824 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
2824 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
2825 | 2825 | } |
2826 | 2826 | |
2827 | 2827 | |
@@ -2833,8 +2833,8 @@ discard block |
||
2833 | 2833 | * |
2834 | 2834 | * @global wpdb $wpdb |
2835 | 2835 | */ |
2836 | -function give_v220_delete_wp_session_data(){ |
|
2836 | +function give_v220_delete_wp_session_data() { |
|
2837 | 2837 | global $wpdb; |
2838 | 2838 | |
2839 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'" ); |
|
2839 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'"); |
|
2840 | 2840 | } |