PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.0.7
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.0.7
1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2.0 All 28 releases
xspeed / includes / class-settings.php

class-settings.php in xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN 1.0.7, at includes/class-settings.php

60 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Settings handling.
4 *
5 * @package XSpeed
6 */
7
8 namespace XSpeed;
9
10 defined( 'ABSPATH' ) || exit;
11
12 class Settings {
13
14 const OPTION_KEY = 'xspeed_options';
15
16 public static function defaults() {
17 // Migrated out of this legacy blob (now per-module storage):
18 // - minify_html / minify_css / minify_js → xspeed_module_minify
19 // - gzip_enabled → xspeed_module_gzip
20 // - cache_expiry / excluded_urls → xspeed_module_cache
21 // Still here (intentionally, drop-in lifecycle):
22 // - cache_enabled (Cache::toggle owns the .htaccess/wp-config edit)
23 return array(
24 'cache_enabled' => false,
25 );
26 }
27
28 public static function get() {
29 $saved = get_option( self::OPTION_KEY, array() );
30 return wp_parse_args( $saved, self::defaults() );
31 }
32
33 public static function update( array $input ) {
34 $current = self::get();
35 $clean = $current;
36
37 // Every former field is now in per-module storage:
38 // - minify_* → MinifyModule, gzip_enabled → GzipModule,
39 // cache_expiry / excluded_urls → CacheModule.
40 // Only cache_enabled lives on here, owned by Cache::toggle's
41 // drop-in lifecycle. All other writes are silently ignored to
42 // keep duplicate sources from re-forming.
43 if ( isset( $input['cache_enabled'] ) ) {
44 $clean['cache_enabled'] = (bool) $input['cache_enabled'];
45 }
46
47 update_option( self::OPTION_KEY, $clean );
48 return $clean;
49 }
50
51 public static function set_defaults() {
52 if ( false === get_option( self::OPTION_KEY ) ) {
53 add_option( self::OPTION_KEY, self::defaults() );
54 }
55 }
56
57 // sanitize_urls() removed — excluded_urls now owned by CacheModule
58 // and validated by Settings_Manager's typed schema (list / item_type).
59 }
60