| 1 |
<?php |
| 2 |
/** |
| 3 |
* The class for retrieving configuration values from a file. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
declare( strict_types=1 ); |
| 11 |
|
| 12 |
namespace SolidWP\Performance\Config\Strategies; |
| 13 |
|
| 14 |
use SolidWP\Performance\Config\Contracts\Strategy; |
| 15 |
use SolidWP\Performance\StellarWP\SuperGlobals\SuperGlobals; |
| 16 |
|
| 17 |
/** |
| 18 |
* Stores and retrieves configuration values from a file. |
| 19 |
* |
| 20 |
* @since 0.1.0 |
| 21 |
* |
| 22 |
* @package SolidWP\Performance |
| 23 |
*/ |
| 24 |
class Site_File extends File implements Strategy { |
| 25 |
|
| 26 |
/** |
| 27 |
* The base path to the config directory. |
| 28 |
* |
| 29 |
* @since 0.1.0 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
protected string $config_dir = WP_CONTENT_DIR . '/cache/solid-performance'; |
| 34 |
|
| 35 |
/** |
| 36 |
* {@inheritdoc} |
| 37 |
*/ |
| 38 |
public function get_config_file_path(): string { |
| 39 |
if ( defined( 'MULTISITE' ) && ! MULTISITE ) { |
| 40 |
return $this->config_dir . '/config.php'; |
| 41 |
} |
| 42 |
|
| 43 |
if ( defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) { |
| 44 |
return $this->config_dir . '/config.php'; |
| 45 |
} |
| 46 |
|
| 47 |
$host = SuperGlobals::get_server_var( 'HTTP_HOST' ); |
| 48 |
|
| 49 |
return "{$this->config_dir}/{$host}/config.php"; |
| 50 |
} |
| 51 |
} |
| 52 |
|