# xspeed/1.0.0/includes/class-settings.php

xSpeed Cache: AI-Powered Performance Hub with MCP, Caching &amp; CDN, version 1.0.0. 82 lines.

- Page: https://pluginprobe.com/plugins/xspeed/1.0.0/code/includes/class-settings.php
- Raw: https://pluginprobe.com/plugins/xspeed/1.0.0/raw/includes/class-settings.php
- Modified: 2026-05-27T11:31:36+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/xspeed/1.0.0/code/includes/class-settings.php#L10-L20`.

```php
<?php
/**
 * Settings handling.
 *
 * @package XSpeed
 */

namespace XSpeed;

defined( 'ABSPATH' ) || exit;

class Settings {

	const OPTION_KEY = 'xspeed_options';

	public static function defaults() {
		return array(
			'cache_enabled'   => false,
			'minify_html'     => false,
			'minify_css'      => false,
			'minify_js'       => false,
			'gzip_enabled'    => false,
			'cache_expiry'    => 24,
			'excluded_urls'   => array(),
		);
	}

	public static function get() {
		$saved = get_option( self::OPTION_KEY, array() );
		return wp_parse_args( $saved, self::defaults() );
	}

	public static function update( array $input ) {
		$current = self::get();
		$clean   = $current;

		foreach ( array( 'cache_enabled', 'minify_html', 'minify_css', 'minify_js', 'gzip_enabled' ) as $key ) {
			if ( isset( $input[ $key ] ) ) {
				$clean[ $key ] = (bool) $input[ $key ];
			}
		}

		if ( isset( $input['cache_expiry'] ) ) {
			$expiry              = absint( $input['cache_expiry'] );
			$clean['cache_expiry'] = max( 1, min( 720, $expiry ) );
		}

		if ( isset( $input['excluded_urls'] ) ) {
			$clean['excluded_urls'] = self::sanitize_urls( $input['excluded_urls'] );
		}

		update_option( self::OPTION_KEY, $clean );
		return $clean;
	}

	public static function set_defaults() {
		if ( false === get_option( self::OPTION_KEY ) ) {
			add_option( self::OPTION_KEY, self::defaults() );
		}
	}

	private static function sanitize_urls( $value ) {
		if ( is_string( $value ) ) {
			$lines = preg_split( '/\r\n|\r|\n/', $value );
		} elseif ( is_array( $value ) ) {
			$lines = $value;
		} else {
			return array();
		}

		$clean = array();
		foreach ( $lines as $line ) {
			$line = trim( sanitize_text_field( $line ) );
			if ( '' === $line ) {
				continue;
			}
			$clean[] = $line;
		}
		return array_values( array_unique( $clean ) );
	}
}

```
