Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CacheExclusion | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| add_to_runtime | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\Performance\Cache; |
| 3 | |
| 4 | use NewfoldLabs\WP\ModuleLoader\Container; |
| 5 | |
| 6 | use function NewfoldLabs\WP\Module\Performance\get_default_cache_exclusions; |
| 7 | |
| 8 | /** |
| 9 | * Cache Exclusion Class |
| 10 | */ |
| 11 | class CacheExclusion { |
| 12 | /** |
| 13 | * Dependency injection container. |
| 14 | * |
| 15 | * @var Container |
| 16 | */ |
| 17 | protected $container; |
| 18 | |
| 19 | /** |
| 20 | * Option used to store all pages should be excluded from cache. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | const OPTION_CACHE_EXCLUSION = 'nfd_performance_cache_exclusion'; |
| 25 | |
| 26 | /** |
| 27 | * Constructor. |
| 28 | * |
| 29 | * @param Container $container the container |
| 30 | */ |
| 31 | public function __construct( Container $container ) { |
| 32 | $this->container = $container; |
| 33 | |
| 34 | add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ) ); |
| 35 | } |
| 36 | /** |
| 37 | * Add values to the runtime object. |
| 38 | * |
| 39 | * @param array $sdk The runtime object. |
| 40 | * |
| 41 | * @return array |
| 42 | */ |
| 43 | public function add_to_runtime( $sdk ) { |
| 44 | return array_merge( $sdk, array( 'cacheExclusion' => get_option( self::OPTION_CACHE_EXCLUSION, get_default_cache_exclusions() ) ) ); |
| 45 | } |
| 46 | } |