Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 29
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3use NewfoldLabs\WP\Module\Performance\BurstSafetyMode\Skip404 as BurstSkip404;
4use NewfoldLabs\WP\Module\Performance\BurstSafetyMode\Browser as BurstBrowser;
5use NewfoldLabs\WP\Module\Performance\Cache\Types\Browser as CacheBrowser;
6use NewfoldLabs\WP\Module\Performance\Cache\ResponseHeaderManager;
7
8$newfold_burst_safety_mode = function_exists( 'get_option' ) ? (bool) get_option( 'newfold_burst_safety_mode', false ) : false;
9$newfold_cache_level       = function_exists( 'newfold_cache_level' ) ? (int) get_option( 'newfold_cache_level', 0 ) : 0;
10
11// Check if Performance feature is enabled and it's necessary reset the cache options
12if ( class_exists( 'NewfoldLabs\WP\Module\Performance\Performance' ) ) {
13    if ( $newfold_burst_safety_mode ) {
14        $browser = new CacheBrowser();
15        $browser::maybeAddRules( $newfold_cache_level );
16        delete_option( 'newfold_burst_safety_mode' );
17    }
18} elseif ( ! $newfold_burst_safety_mode && defined( 'BLUEHOST_PLUGIN_DIR' ) ) {
19    $files_to_include = array(
20        'wp-htaccess_api'                        => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-htaccess/includes/Api.php',
21        'wp_htaccess_fragment'                   => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-htaccess/includes/Fragment.php',
22        'wp_htaccess_options'                    => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-htaccess/includes/Options.php',
23        'wp_htaccess_context'                    => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-htaccess/includes/Context.php',
24        'wp_performance_cache_type_fragment'     => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-performance/includes/Cache/Types/Fragments/BrowserCacheFragment.php',
25        'wp_forge_htaccess'                      => BLUEHOST_PLUGIN_DIR . 'vendor/wp-forge/wp-htaccess-manager/includes/htaccess.php',
26        'wp_forge_htaccess_functions'            => BLUEHOST_PLUGIN_DIR . 'vendor/wp-forge/wp-htaccess-manager/includes/functions.php',
27        'wp_performance_skip404_fragment'        => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-performance/includes/Skip404/Fragments/Skip404Fragment.php',
28        'wp_performance_skip404'                 => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-performance/includes/BurstSafetyMode/Skip404.php',
29        'wp_performance_browser'                 => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-performance/includes/BurstSafetyMode/Browser.php',
30        'wp_performance_response_header_manager' => BLUEHOST_PLUGIN_DIR . 'vendor/newfold-labs/wp-module-performance/includes/BurstSafetyMode/ResponseHeaderManager.php',
31    );
32
33    foreach ( $files_to_include as $file_path ) {
34        if ( file_exists( $file_path ) ) {
35            require_once $file_path;
36        }
37    }
38
39    define( 'BURST_SAFETY_CACHE_LEVEL', 3 );
40
41    $skip404 = new BurstSkip404();
42
43    if ( BURST_SAFETY_CACHE_LEVEL !== $newfold_cache_level && class_exists( BurstBrowser::class ) ) {
44        $browser = new BurstBrowser();
45    }
46
47    update_option( 'newfold_burst_safety_mode', true );
48}