diff --git a/source/admin/class-wpoven-triple-cache-admin.php b/source/admin/class-wpoven-triple-cache-admin.php index 4e96190..06aec1f 100755 --- a/source/admin/class-wpoven-triple-cache-admin.php +++ b/source/admin/class-wpoven-triple-cache-admin.php @@ -450,7 +450,6 @@ function wildcard_match($pattern, $subject) if (!preg_match($pattern, $subject, $regs)) return false; - return true; } diff --git a/source/libs/backend.class.php b/source/libs/backend.class.php index 4c3faba..2852aa7 100755 --- a/source/libs/backend.class.php +++ b/source/libs/backend.class.php @@ -69,7 +69,7 @@ function autoprefetch_config_wp_enqueue_scripts() * * https://wordpress.stackexchange.com/questions/298762/wp-add-inline-script-without-dependency/311279#311279 */ - wp_register_script('wpocf_auto_prefetch_url', '', [], '', true); + wp_register_script('wpocf_auto_prefetch_url', '', [], '1.0.0', true); wp_enqueue_script('wpocf_auto_prefetch_url'); // Making sure we are not adding the following inline script for AMP endpoints as they are not gonna work anyway and will be striped out by the AMP system diff --git a/source/libs/cache_controller.class.php b/source/libs/cache_controller.class.php index 881ac86..f671378 100755 --- a/source/libs/cache_controller.class.php +++ b/source/libs/cache_controller.class.php @@ -1517,7 +1517,7 @@ function purge_cache_queue_write($urls = array(), $purge_all = false) if (file_exists($cache_queue_path)) { - $wpocf_cache_queue = json_decode(file_get_contents($cache_queue_path), true); + $wpocf_cache_queue = json_decode(wp_remote_get($cache_queue_path), true); if (!is_array($wpocf_cache_queue) || (is_array($wpocf_cache_queue) && (!isset($wpocf_cache_queue['purge_all']) || !isset($wpocf_cache_queue['urls'])))) { $this->unlock_cache_purge_queue(); @@ -1539,7 +1539,15 @@ function purge_cache_queue_write($urls = array(), $purge_all = false) $urls = array(); $wpocf_cache_queue = array('purge_all' => $purge_all, 'urls' => $urls); } - file_put_contents($cache_queue_path, wp_json_encode($wpocf_cache_queue)); + + global $wp_filesystem; + // Load the WP_Filesystem API if not already loaded + if (empty($wp_filesystem)) { + require_once ABSPATH . 'wp-admin/includes/file.php'; + WP_Filesystem(); + } + + $wp_filesystem->put_contents($cache_queue_path, wp_json_encode($wpocf_cache_queue), FS_CHMOD_FILE); $this->unlock_cache_purge_queue(); } @@ -1608,7 +1616,7 @@ function purge_cache_queue_job() $this->lock_cache_purge_queue(); - $wpocf_cache_queue = json_decode(file_get_contents($cache_queue_path), true); + $wpocf_cache_queue = json_decode(wp_remote_get($cache_queue_path), true); if (isset($wpocf_cache_queue['purge_all']) && $wpocf_cache_queue['purge_all']) { $this->purge_all(false, false); @@ -1616,7 +1624,7 @@ function purge_cache_queue_job() $this->purge_urls($wpocf_cache_queue['urls'], false); } - @unlink($cache_queue_path); + @wp_delete_file($cache_queue_path); $this->unlock_cache_purge_queue();