HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux aritmodecarnaval.es 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: www-data (33)
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: /home/www/torresncgolf/wp-content/plugins/wp-migrate-db/class/Common/Settings/Settings.php
<?php

namespace DeliciousBrains\WPMDB\Common\Settings;

use DeliciousBrains\WPMDB\Common\Filesystem\Filesystem;
use DeliciousBrains\WPMDB\Common\Helpers;
use DeliciousBrains\WPMDB\Common\Util\Util;

class Settings
{

    /**
     * @var Util
     */
    public $util;
    /**
     * @var
     */
    private $settings;
    /**
     * @var
     */
    private static $static_settings;
    // The constructor is private
    // to prevent initiation with outer code.
    /**
     * @var Filesystem
     */
    private $filesystem;

    public function __construct(Util $util, Filesystem $filesystem)
    {
        $this->util = $util;

        // @TODO this shouldn't be fired every time the Settings class is called...
        $this->load_settings();
        $this->filesystem = $filesystem;
    }

    static function get_setting($setting)
    {
        if (isset(self::$static_settings[$setting])) {
            return self::$static_settings[$setting];
        }

        throw new \InvalidArgumentException(__('Setting does not exist', 'wp-migrate-db'));
    }

    public function get_settings_for_frontend()
    {
        // Always get fresh settings for the frontend.
        $this->load_settings();
        $existing_settings = $this->settings;

        if (!empty($existing_settings['licence'])) {
            $masked_licence                      = $this->util->mask_licence($existing_settings['licence']);
            $existing_settings['masked_licence'] = $masked_licence;
        }

        $existing_settings['plugins']         = $this->filesystem->get_local_plugins();

        return $existing_settings;
    }

    public function get_settings()
    {
        // Assumes load_settings() has been called in base plugin (WPMigrateDB)
        return $this->settings;
    }

    public function load_settings()
    {
        $update_settings = false;
        $this->settings  = get_site_option('wpmdb_settings');

        $default_settings = array(
            'key'                        => $this->util->generate_key(),
            'allow_pull'                 => false,
            'allow_push'                 => false,
            'profiles'                   => array(),
            'licence'                    => '',
            'verify_ssl'                 => false,
            'whitelist_plugins'          => array(),
            'max_request'                => min(1024 * 1024, $this->util->get_bottleneck('max')),
            'delay_between_requests'     => 0,
            'prog_tables_hidden'         => true,
            'pause_before_finalize'      => false,
            'allow_tracking'             => null,
            'high_performance_transfers' => false
        );

        // if we still don't have settings exist this must be a fresh install, set up some default settings
        if (false === $this->settings) {
            $this->settings  = $default_settings;
            $update_settings = true;
        } else {
            /*
             * When new settings are added an existing customer's db won't have the new settings.
             * They're added here to circumvent array index errors in debug mode.
             */
            foreach ($default_settings as $key => $value) {
                if (!isset($this->settings [$key])) {
                    $this->settings[$key] = $value;
                    $update_settings      = true;
                }
            }
        }

        $is_compat_mode = $this->util->is_muplugin_installed();

        if (!isset($this->settings['compatibility_mode']) || $is_compat_mode !== $this->settings['compatibility_mode']) {
            //override compatibility mode
            $this->settings['compatibility_mode'] = $is_compat_mode;
            $update_settings                      = true;
        }


        if ($update_settings) {
            update_site_option('wpmdb_settings', $this->settings);
        }

        $user_licence = Helpers::get_user_licence_key();
        if ( $user_licence ) {
            $this->settings['licence'] = $user_licence;
        }

        self::$static_settings = $this->settings;
    }
}