PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.9.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.9.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Preload / Preload_Mode_Manager.php

Preload_Mode_Manager.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.9.0, at src/Performance/Preload/Preload_Mode_Manager.php

71 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Preload Mode Manager, allows enabling/disabling and getting the status of
4 * high performance mode.
5 *
6 * @package SolidWP\Performance
7 */
8
9 declare( strict_types=1 );
10
11 namespace SolidWP\Performance\Preload;
12
13 use SolidWP\Performance\Config\Config;
14
15 /**
16 * The Preload Mode Manager, allows enabling/disabling and getting the status of
17 * high performance mode.
18 *
19 * @package SolidWP\Performance
20 */
21 class Preload_Mode_Manager {
22
23 /**
24 * @var Config
25 */
26 private Config $config;
27
28 /**
29 * The preload high performance mode config key.
30 *
31 * @var string
32 */
33 private string $config_key;
34
35 /**
36 * @param Config $config The config object.
37 * @param string $config_key The preload high performance mode config key.
38 */
39 public function __construct( Config $config, string $config_key = 'page_cache.preload.high_performance_mode' ) {
40 $this->config = $config;
41 $this->config_key = $config_key;
42 }
43
44 /**
45 * Check if high performance mode is enabled.
46 *
47 * @return bool
48 */
49 public function is_high_performance_mode(): bool {
50 return (bool) $this->config->refresh()->get( $this->config_key );
51 }
52
53 /**
54 * Enable high performance mode.
55 *
56 * @return void
57 */
58 public function enable_high_performance_mode(): void {
59 $this->config->set( $this->config_key, true )->save();
60 }
61
62 /**
63 * Disable high performance mode.
64 *
65 * @return void
66 */
67 public function disable_high_performance_mode(): void {
68 $this->config->set( $this->config_key, false )->save();
69 }
70 }
71