PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Onboarding / Migrations / SetFormDonationLevelsToStrings.php

SetFormDonationLevelsToStrings.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Onboarding/Migrations/SetFormDonationLevelsToStrings.php

65 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Onboarding\Migrations;
4
5 use Give\Framework\Migrations\Contracts\Migration;
6 use Give\Onboarding\FormRepository;
7
8 /**
9 * This resolves an issue where the donation level data for the form created during onboarding was serialized as
10 * integers instead of strings, causing issues throughout
11 *
12 * @since 2.13.4 preserve additional donation level data
13 * @since 2.13.3
14 */
15 class SetFormDonationLevelsToStrings extends Migration
16 {
17 /**
18 * @var FormRepository
19 */
20 private $formRepository;
21
22 /**
23 * @inheritDoc
24 */
25 public static function id()
26 {
27 return 'set-form-donation-levels-to-strings';
28 }
29
30 /**
31 * @inheritDoc
32 */
33 public static function timestamp()
34 {
35 return strtotime('2020-09-01 11:47:00');
36 }
37
38 public function __construct(FormRepository $formRepository)
39 {
40 $this->formRepository = $formRepository;
41 }
42
43 /**
44 * @inheritDoc
45 */
46 public function run()
47 {
48 $formId = $this->formRepository->getDefaultFormID();
49
50 if (empty($formId)) {
51 return;
52 }
53
54 $donationLevels = give_get_meta($formId, '_give_donation_levels', true);
55
56 foreach ($donationLevels as &$level) {
57 $level['_give_id']['level_id'] = (string)$level['_give_id']['level_id'];
58 $level['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']);
59 }
60 unset($level);
61
62 update_post_meta($formId, '_give_donation_levels', $donationLevels);
63 }
64 }
65