HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/options.class.php
<?php

/**
 * @package Unlimited Elements
 * @author UniteCMS http://unitecms.net
 * @copyright Copyright (c) 2016 UniteCMS
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
 */

if ( ! defined( 'ABSPATH' ) ) exit;

class UCAdminNoticesOptions{

	const OPTIONS_KEY = 'unlimited_elements_notices';

	private static $optionsCache = array();

	/**
	 * get the option value
	 */
	public static function getOption($key, $fallback = null){

		$options = self::getOptions();
		$value = UniteFunctionsUC::getVal($options['options'], $key, $fallback);

		return $value;
	}

	/**
	 * set the option value
	 */
	public static function setOption($key, $value){

		$options = self::getOptions();
		$options['options'][$key] = $value;

		self::setOptions($options);
	}

	/**
	 * get the notice all options
	 */
	public static function getNoticeOptions($id){

		$options = self::getOptions();
		$noticeOptions = UniteFunctionsUC::getVal($options['notices'], $id, array());

		return $noticeOptions;
	}

	/**
	 * get the notice option value
	 */
	public static function getNoticeOption($id, $key, $fallback = null){

		$options = self::getOptions();
		$noticeOptions = self::getNoticeOptions($id);

		$value = UniteFunctionsUC::getVal($noticeOptions, $key, $fallback);

		return $value;
	}

	/**
	 * set the notice option value
	 */
	public static function setNoticeOption($id, $key, $value){

		$options = self::getOptions();
		$noticeOptions = self::getNoticeOptions($id);

		$noticeOptions[$key] = $value;

		$options['notices'][$id] = $noticeOptions;

		self::setOptions($options);
	}

	/**
	 * delete the notice option value
	 */
	public static function deleteNoticeOption($id, $key){

		$options = self::getOptions();
		$noticeOptions = self::getNoticeOptions($id);

		unset($noticeOptions[$key]);

		$options['notices'][$id] = $noticeOptions;

		self::setOptions($options);
	}

	/**
	 * get all options
	 */
	private static function getOptions(){

		if(empty(self::$optionsCache)){
			self::$optionsCache = get_option(self::OPTIONS_KEY, array(
				'options' => array(),
				'notices' => array(),
			));
		}

		return self::$optionsCache;
	}

	/**
	 * set all options
	 */
	private static function setOptions($options){

		self::$optionsCache = $options;

		update_option(self::OPTIONS_KEY, $options);
	}

}