403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.133.113.227
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/cwd/plugins/give/src/DonationForms/Migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/cwd/plugins/give/src/DonationForms/Migrations/UpdateDonationLevelsSchema.php
<?php

namespace Give\DonationForms\Migrations;

use Give\DonationForms\Repositories\DonationFormRepository;
use Give\Framework\Migrations\Contracts\Migration;

/**
 * Update the donation levels schema to support descriptions
 *
 * @since 3.12.0
 */
class UpdateDonationLevelsSchema extends Migration
{
    /**
     * @inheritdoc
     */
    public static function id()
    {
        return 'donation-forms-donation-levels-schema';
    }

    /**
     * @inheritdoc
     */
    public static function title()
    {
        return 'Update Donation Levels schema to support descriptions';
    }

    /**
     * @inheritdoc
     */
    public static function timestamp()
    {
        return strtotime('2024-04-22');
    }

    /**
     * @since 3.12.0
     */
    public function run()
    {
        $forms = give(DonationFormRepository::class)
            ->prepareQuery()
            ->whereIsNotNull("give_formmeta_attach_meta_fields.meta_value")
            ->getAll();

        if ( ! $forms) {
            return;
        }

        foreach ($forms as $form) {
            $amountBlock = $form->blocks->findByName('givewp/donation-amount');

            if ( ! $amountBlock) {
                continue;
            }

            $blockAttributes = $amountBlock->getAttributes();
            $levels = $blockAttributes["levels"];
            $defaultLevel = $blockAttributes["defaultLevel"] ?? 0;

            if ( ! is_array($levels) || empty($levels) || isset($levels[0]['value'])) {
                continue;
            }

            $levels = array_map(function($level) use ($defaultLevel) {
                return [
                    'value' => $level,
                    'label' => '',
                    'checked' => $level === $defaultLevel,
                ];
            }, $levels);

            $amountBlock->setAttribute('levels', $levels);
            $form->save();
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit