HEX
Server: Apache
System: Linux host.fiblib.com 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: agritoday (1002)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/agritoday/www/wp-content/plugins/td-composer/css-live/includes/td_live_css_storage.php
<?php
/**
 * Created by ra.
 * Date: 7/18/2016
 */

class td_live_css_css_storage {

	private static $is_shutdown_hooked = false;
	private static $is_local_storage_read = false; // true if we read the local storage form db

	private static $local_storage = array();

	static function update( $less_or_css, $new_value ) {

		// read the cache from db if needed
		self::read_local_storage();

		if ( empty($new_value) ) {

			if ( isset(self::$local_storage) ) {
				//echo 'rarara';

				// unset the key
				if (isset(self::$local_storage[$less_or_css])) {
					unset(self::$local_storage[$less_or_css]);
				}

				// double check to see if we have empty keys
				if (empty(self::$local_storage['less']) && empty(self::$local_storage['css'])) {
					self::$local_storage = null;
					//unset (self::$local_storage);
				}
			}


		} else {
			self::$local_storage[$less_or_css] = $new_value;
		}

		// make sure that we hook only once
		if ( self::$is_shutdown_hooked === false ) {
			add_action( 'shutdown', array( __CLASS__, 'on_shutdown_save_log' ) );
			self::$is_shutdown_hooked = true;
		}

	}

	static function get( $less_or_css ) {

		// read the cache from db if needed
		self::read_local_storage();

		if ( !empty(self::$local_storage[$less_or_css]) ) {
			return self::$local_storage[$less_or_css];
		}

		return '';
	}

	private static function read_local_storage() {
		if ( self::$is_local_storage_read === false ) {
			self::$local_storage = (array) get_option('td_live_css_local_storage');
			self::$is_local_storage_read = true;
		}
	}

	// save the log if needed
	static function on_shutdown_save_log() {
		update_option('td_live_css_local_storage', self::$local_storage );
	}

}