# defender-security/6.2.4/src/model/setting/class-security-tweaks.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 6.2.4. 224 lines.

- Page: https://pluginprobe.com/plugins/defender-security/6.2.4/code/src/model/setting/class-security-tweaks.php
- Raw: https://pluginprobe.com/plugins/defender-security/6.2.4/raw/src/model/setting/class-security-tweaks.php
- Modified: 2026-08-24T08:19:12+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/6.2.4/code/src/model/setting/class-security-tweaks.php#L10-L20`.

```php
<?php
/**
 * Handle tweaks settings.
 *
 * @package WP_Defender\Model\Setting
 */

namespace WP_Defender\Model\Setting;

use Calotes\Model\Setting;

/**
 * Model for tweaks settings.
 */
class Security_Tweaks extends Setting {

	/**
	 * Option name.
	 *
	 * @var string
	 */
	protected $table = 'hardener_settings';

	/**
	 * Store a list of issues tweaks, as slug.
	 *
	 * @var array
	 */
	public $issues = array();

	/**
	 * Store a list of fixed tweaks, as slug.
	 *
	 * @var array
	 */
	public $fixed = array();

	/**
	 * Store a list of ignored tweaks, as slug.
	 *
	 * @var array
	 */
	public $ignore = array();

	/**
	 * Contains all the data generated by rules.
	 *
	 * @var array
	 */
	public $data = array();

	/**
	 * Last time visit into the hardener page.
	 *
	 * @var integer
	 */
	public $last_seen;

	/**
	 * Last notification sent out.
	 *
	 * @var integer
	 */
	public $last_sent;
	/**
	 * Automate tweaks
	 *
	 * @var bool
	 */
	public $automate = false;

	/**
	 * Check if a tweak is ignored.
	 *
	 * @param string $slug  Tweak slug.
	 *
	 * @return bool
	 */
	public function is_tweak_ignore( string $slug ): bool {
		// Empty ignored tweak is string on old versions, so change it to array.
		if ( is_string( $this->ignore ) ) {
			$this->ignore = '' === $this->ignore ? array() : array( $this->ignore );
			$this->save();
		}

		return in_array( $slug, $this->ignore, true );
	}

	/**
	 * Is the tweak in the Issue list?.
	 *
	 * @param string $slug  Tweak slug.
	 *
	 * @return bool
	 */
	public function is_tweak_issue( string $slug ): bool {
		return in_array( $slug, $this->issues, true );
	}

	/**
	 * Mark a tweak as actioned.
	 *
	 * @param  string $status  Status.
	 * @param  string $slug  Tweak slug.
	 */
	public function mark( $status, $slug ) {
		foreach ( array(
			\WP_Defender\Controller\Security_Tweaks::STATUS_ISSUES,
			\WP_Defender\Controller\Security_Tweaks::STATUS_RESOLVE,
			\WP_Defender\Controller\Security_Tweaks::STATUS_IGNORE,
		) as $collection_name ) {
			$collection = $this->get_collection( $collection_name );

			if ( ! is_array( $collection ) ) {
				continue;
			}

			$index = array_search( $slug, $collection, true );
			if ( false !== $index ) {
				unset( $collection[ $index ] );
			}
			$this->set_collection( $collection_name, $collection );
		}

		if ( \WP_Defender\Controller\Security_Tweaks::STATUS_RESTORE === $status ) {
			$status = \WP_Defender\Controller\Security_Tweaks::STATUS_ISSUES;
		}

		if ( ! property_exists( $this, $status ) ) {
			return;
		}

		try {
			$collection = $this->get_collection( $status );
		} catch ( \InvalidArgumentException $e ) {
			return;
		}

		$collection[] = $slug;
		$this->set_collection( $status, $collection );
		$this->save();
	}

	/**
	 * Get a tweak collection by name.
	 *
	 * @param string $name Collection name.
	 *
	 * @return array
	 *
	 * @throws \InvalidArgumentException Invalid collection name.
	 */
	public function get_collection( string $name ): array {
		switch ( $name ) {
			case \WP_Defender\Controller\Security_Tweaks::STATUS_ISSUES:
				return $this->issues;

			case \WP_Defender\Controller\Security_Tweaks::STATUS_RESOLVE:
				return $this->fixed;

			case \WP_Defender\Controller\Security_Tweaks::STATUS_IGNORE:
				return $this->ignore;

			default:
				throw new \InvalidArgumentException( 'Invalid collection name.' );
		}
	}

	/**
	 * Set a tweak collection by name.
	 *
	 * @param string $name  Collection name.
	 * @param array  $value Collection value.
	 *
	 * @throws \InvalidArgumentException Invalid collection name.
	 */
	private function set_collection( string $name, array $value ): void {
		switch ( $name ) {
			case \WP_Defender\Controller\Security_Tweaks::STATUS_ISSUES:
				$this->issues = $value;
				break;

			case \WP_Defender\Controller\Security_Tweaks::STATUS_RESOLVE:
				$this->fixed = $value;
				break;

			case \WP_Defender\Controller\Security_Tweaks::STATUS_IGNORE:
				$this->ignore = $value;
				break;

			default:
				throw new \InvalidArgumentException( 'Invalid collection name.' );
		}
	}

	/**
	 * Define settings labels.
	 *
	 * @return array
	 */
	public function labels(): array {
		return array(
			'data'     => 'data',
			'fixed'    => esc_html__( 'Actioned', 'defender-security' ),
			'issues'   => esc_html__( 'Recommendations', 'defender-security' ),
			'ignore'   => esc_html__( 'Ignored', 'defender-security' ),
			'automate' => 'automate',
		);
	}

	/**
	 * Todo: Find a less expensive way.
	 *
	 * @return array
	 */
	public function get_tweak_types(): array {
		return array(
			'count_fixed'   => count( $this->fixed ),
			'count_ignored' => count( $this->ignore ),
			'count_issues'  => count( $this->issues ),
		);
	}
}

```
