# defender-security/3.0.1/framework/model/setting.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 3.0.1. 76 lines.

- Page: https://pluginprobe.com/plugins/defender-security/3.0.1/code/framework/model/setting.php
- Raw: https://pluginprobe.com/plugins/defender-security/3.0.1/raw/framework/model/setting.php
- Modified: 2020-12-28T12:52:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/3.0.1/code/framework/model/setting.php#L10-L20`.

```php
<?php

namespace Calotes\Model;

use Calotes\Base\Model;
use WP_Defender\Component\Error_Code;

class Setting extends Model {
	protected $exclude = array( 'table' );

	public function __construct() {
		// we parse the annotations here, and only one
		$this->parse_annotations();
		$this->before_load();
		$this->load();
		$this->after_load();
		$this->sanitize();
	}

	public function save() {
		$data = $this->prepare_data();
		$data = json_encode( $data );
		$ret  = update_site_option( $this->table, $data );
		if ( $ret === false ) {
			$this->internal_logging[] = sprintf( 'Saving fail on %s with data %s', $this->table, json_encode( $data ) );
		}
	}

	/**
	 * Load data
	 *
	 * @throws \ReflectionException
	 */
	public function load() {
		$time = microtime( true );
		if ( empty( $this->table ) ) {
			throw new \Exception( 'Table must be defined before using' );
		}

		$data = get_site_option( $this->table );
		if ( $data === false ) {
			return;
		}

		if ( ! is_array( $data ) ) {
			$data = json_decode( $data, true );
		}

		if ( ! is_array( $data ) ) {
			return;
		}

		$data = $this->prepare_data( $data );
		$this->import( $data );
		$this->log( sprintf( 'loaded %s - %s', $this->table, microtime( true ) - $time ) );
	}

	public function delete() {
		delete_site_option( $this->table );
	}

	/**
	 * Empty function
	 */
	protected function after_load() {
		return 'For child class to implement';
	}

	/**
	 * @return string
	 */
	protected function before_load() {
		return 'For child class to implement';
	}
}

```
