HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpmuhibbah_err/wp-content/plugins/give/src/PaymentGateways/PaypalSettingPage.php
<?php

namespace Give\PaymentGateways;

use Give\PaymentGateways\Gateways\PayPalStandard\PayPalStandard;
use Give\PaymentGateways\PayPalCommerce\AdminSettingFields;
use Give\PaymentGateways\PayPalCommerce\PayPalCommerce;

use function give_get_current_setting_section as getCurrentSettingSection;

/**
 * Class PaypalSettingSection
 * @package Give\PaymentGateways
 *
 * @sicne 2.9.0
 */
class PaypalSettingPage implements SettingPage
{
    /**
     * @var PayPalCommerce
     */
    private $payPalCommerce;

    /**
     * @var PayPalStandard
     */
    private $paypalStandard;

    /**
     * Register properties
     *
     * @since 2.9.0
     *
     * @param PayPalStandard $paypalStandard
     *
     * @param PayPalCommerce $payPalCommerce
     */
    public function __construct(PayPalCommerce $payPalCommerce, PayPalStandard $paypalStandard)
    {
        $this->payPalCommerce = $payPalCommerce;
        $this->paypalStandard = $paypalStandard;
    }

    /**
     * @inheritDoc
     */
    public function boot()
    {
        add_action('give_get_groups_paypal', [$this, 'getGroups']);
        add_filter('give_get_settings_gateways', [$this, 'registerPaypalSettings']);
        add_filter('give_get_sections_gateways', [$this, 'registerPaypalSettingSection'], 5);

        // Load custom setting fields.
        /* @var AdminSettingFields $adminSettingFields */
        $adminSettingFields = give(AdminSettingFields::class);
        $adminSettingFields->boot();
    }

    /**
     * @inheritDoc
     */
    public function getId()
    {
        return 'paypal';
    }

    /**
     * @inheritDoc
     */
    public function getName()
    {
        return esc_html__('PayPal', 'give');
    }

    /**
     * @inheritDoc
     */
    public function getSettings()
    {
        $settings[$this->payPalCommerce::id()] = $this->payPalCommerce->getOptions();
        $settings[$this->paypalStandard::id()] = $this->paypalStandard->getOptions();

        return $settings;
    }

    /**
     * Get groups.
     *
     * @since 2.9.0
     *
     * @return array
     */
    public function getGroups()
    {
        return [
            $this->payPalCommerce::id() => $this->payPalCommerce->getName(),
            $this->paypalStandard::id() => $this->paypalStandard->getName(),
        ];
    }

    /**
     * Register settings.
     *
     * @since 2.9.0
     *
     * @param array $settings
     *
     * @return array
     */
    public function registerPaypalSettings($settings)
    {
        $currentSection = getCurrentSettingSection();

        if ($currentSection === $this->getId()) {
            $settings = $this->getSettings();
        }

        return $settings;
    }

    /**
     * Register setting section.
     *
     * @since 2.9.0
     *
     * @param array $sections
     *
     * @return array
     */
    public function registerPaypalSettingSection($sections)
    {
        $sections[$this->getId()] = $this->getName();

        return $sections;
    }
}