PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/asktraining.online/wp-content/plugins/gdpr-framework/src/Options/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/asktraining.online/wp-content/plugins/gdpr-framework/src/Options/Options.php

<?php

namespace Codelight\GDPR\Options;

/**
 * Main class for handling options on a non-multisite install.
 * Adapted from https://carlalexander.ca/designing-classes-wordpress-options-api/
 *
 * Class Options
 *
 * @package Codelight\GDPR\Options
 */
class Options extends OptionsBase
{
    /**
     * Gets the option for the given name. Returns the default value if the value does not exist.
     *
     * @param string $name
     * @param mixed  $default
     *
     * @return mixed
     */
    public function get($name, $default = null, $enableFilter = true)
    {
        $value = get_option($this->prefix($name), $default);

        if ($enableFilter) {
            $value = apply_filters("gdpr/options/get/{$name}", $value);
        }
        
        if (is_array($default) && !is_array($value)) {
            $value = (array) $value;
        }

        return $value;
    }

    /**
     * Sets an option. Overwrites the existing option if the name is already in use.
     *
     * @param string $name
     * @param mixed  $value
     */
    public function set($name, $value, $enableFilter = true)
    {
        if ($enableFilter) {
            $value = apply_filters("gdpr/options/set/{$name}", $value, get_option($this->prefix($name)));
        }

        update_option(
            $this->prefix($name),
            $value,
            false
        );
    }

    /**
     * Removes the option with the given name.
     *
     * @param string $name
     */
    public function delete($name)
    {
        delete_option($this->prefix($name));
    }
}