HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/lcc.kaunokolegija.lt/wp-content/plugins/wp-menu-icons/lib/models/class-base.php
<?php

namespace QuadLayers\WPMI\Models;

/**
 * Model Class
 */
abstract class Base {

	private $cache   = array();
	protected $table = null;

	protected function get_defaults() {
		return array();
	}

	protected function save_all( $data = null ) {
		if ( ! $this->table ) {
			error_log( 'Model can\'t be accesed directly' );
			die();
		}
		$status = update_option( $this->table, $data );
		if ( $status ) {
			$this->cache[ $this->table ] = $data;
		}
		return $status;
	}

	protected function get_all() {
		if ( ! $this->table ) {
			error_log( 'Model can\'t be accesed directly' );
			die();
		}

		if ( ! isset( $this->cache[ $this->table ] ) ) {
			$this->cache[ $this->table ] = get_option( $this->table, array() );
		}

		return $this->cache[ $this->table ];
	}

	protected function delete_all() {
		delete_option( $this->table );
	}
}