PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.1.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.1.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 / functions / config.php

config.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.1.0, at src/functions/config.php

76 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Global functions that provide access to the plugin configuration.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 use SolidWP\Performance\Config\Config;
11 use SolidWP\Performance\Config\Strategies\Network;
12 use SolidWP\Performance\Config\Strategies\Network_File;
13 use SolidWP\Performance\Config\Strategies\Pipeline;
14 use SolidWP\Performance\Config\Strategies\Site;
15 use SolidWP\Performance\Config\Strategies\Site_File;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 /**
22 * Returns the config that is created from a set of defaults, site settings, and network settings.
23 *
24 * @since 0.1.0
25 *
26 * @param string $key The key to retrieve from the config in dot notation.
27 *
28 * @return mixed
29 */
30 function swpsp_config_get( string $key ) {
31 $config = swpsp_register_config();
32 return $config->get( $key );
33 }
34
35 /**
36 * Returns a registered instance of config with all the necessary strategies.
37 *
38 * @since 0.1.0
39 *
40 * @return Config
41 */
42 function swpsp_register_config() {
43 // Temporary fix for out of sync advanced-cache.php until that feature is released: PR 109.
44 if ( ! function_exists( 'swpsp_plugin' ) ) {
45 require_once __DIR__ . '/app.php';
46 }
47
48 $container = swpsp_plugin()->container();
49
50 if ( $container->isBound( Config::class ) ) {
51 return $container->get( Config::class );
52 }
53
54 $pipeline = new Pipeline( $container );
55 $pipeline->pipes(
56 [
57 Site::class,
58 Site_File::class,
59 ]
60 );
61
62 if ( is_multisite() ) {
63 $pipeline->pipe(
64 [
65 Network::class,
66 Network_File::class,
67 ]
68 );
69 }
70
71 $config = new Config( $pipeline );
72 $container->bind( Config::class, $config );
73
74 return $config;
75 }
76