From 772cc1e40d5b2f2d355863011254eda1ec9c459a Mon Sep 17 00:00:00 2001
From: Armando Liccardo
Date: Thu, 27 Feb 2025 11:37:13 +0000
Subject: [PATCH] moved file cache fix function to CacheManager class
---
includes/CacheManager.php | 15 +++++++++++++++
includes/Performance.php | 16 ----------------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/includes/CacheManager.php b/includes/CacheManager.php
index def8872..20c17da 100644
--- a/includes/CacheManager.php
+++ b/includes/CacheManager.php
@@ -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;
@@ -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' ) );
}
/**
@@ -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;
+ }
+ }
}
diff --git a/includes/Performance.php b/includes/Performance.php
index 017c681..f6a8887 100644
--- a/includes/Performance.php
+++ b/includes/Performance.php
@@ -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;
@@ -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;
- }
}
/**