Skip to content

Commit

Permalink
moved file cache fix function to CacheManager class
Browse files Browse the repository at this point in the history
  • Loading branch information
geckod22 committed Feb 27, 2025
1 parent 33118e8 commit 772cc1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
15 changes: 15 additions & 0 deletions includes/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NewfoldLabs\WP\Module\Performance;

use NewfoldLabs\WP\Module\Performance\CacheTypes\CacheBase;
use NewfoldLabs\WP\Module\Performance\CacheTypes\File;
use NewfoldLabs\WP\ModuleLoader\Container;
use WP_Forge\Collection\Collection;

Expand Down Expand Up @@ -39,6 +40,8 @@ class CacheManager {
*/
public function __construct( Container $container ) {
$this->container = $container;

add_action( 'init', array( $this, 'remove_file_cache_htaccess_for_bh_hg' ) );
}

/**
Expand Down Expand Up @@ -109,4 +112,16 @@ public function getInstances() {

return $instances;
}
/**
* Remove the .htaccess rules for the file cache if the brand is Bluehost or HostGator.
*/
public function remove_file_cache_htaccess_for_bh_hg() {
$brand = $this->container->plugin()->brand;
$fixed_bh_hg = get_option( 'nfd_file_cache_fixed_bh_hg', false );
if ( ( 'bluehost' === $brand || 'hostgator' !== $brand ) && ! $fixed_bh_hg ) {
File::removeRules();
update_option( 'nfd_file_cache_fixed_bh_hg', true );
return;
}
}
}
16 changes: 0 additions & 16 deletions includes/Performance.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use NewfoldLabs\WP\Module\Performance\RestApi\RestApi;
use NewfoldLabs\WP\Module\Performance\Data\Constants;
use NewfoldLabs\WP\Module\Performance\HealthChecks;
use NewfoldLabs\WP\Module\Performance\CacheTypes\File;
use NewfoldLabs\WP\Module\Performance\LinkPrefetch\LinkPrefetch;
use NFD_CLI;

Expand Down Expand Up @@ -89,21 +88,6 @@ public function __construct( Container $container ) {
}

add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ), 100 );

add_action( 'init', array( $this, 'remove_file_cache_htaccess_for_bh_hg' ) );
}

/**
* Remove the .htaccess rules for the file cache if the brand is Bluehost or HostGator.
*/
public function remove_file_cache_htaccess_for_bh_hg() {
$brand = $this->container->plugin()->brand;
$fixed_bh_hg = get_option( 'nfd_file_cache_fixed_bh_hg', false );
if ( ( 'bluehost' === $brand || 'hostgator' !== $brand ) && ! $fixed_bh_hg ) {
File::removeRules();
update_option( 'nfd_file_cache_fixed_bh_hg', true );
return;
}
}

/**
Expand Down

0 comments on commit 772cc1e

Please sign in to comment.