config = $config; $this->wp_config = $wp_config; $this->purge = $purge; $this->advanced_cache = $advanced_cache; } /** * Enables the page cache. * * @since 0.1.0 * * @return bool true on success, false on failure */ public function on(): bool { return $this->wp_config->set_wp_cache( 'true' ); } /** * Enables the page cache. * * @since 0.1.0 * * @return bool true on success, false on failure */ public function off(): bool { return $this->wp_config->set_wp_cache( 'false' ); } /** * Checks if the page cache is currently enabled. * * @since 0.1.0 * * @return bool true when enabled, false when disabled. */ public function is_on(): bool { return $this->wp_config->get_wp_cache_status(); } /** * Clears all pages from the page cache. * * @since 0.1.0 * * @return bool */ public function clear(): bool { return $this->purge->all_pages(); } /** * Regenerates the advanced-cache.php file. * * @since 0.1.0 * * @return bool */ public function regenerate_advanced_cache(): bool { return $this->advanced_cache->generate(); } /** * Gets the current status of debug mode. * * @since 0.1.0 * * @return bool */ public function is_debug_on(): bool { return $this->config->get( 'page_cache.debug' ); } /** * Sets the state of debug mode. * * @since 0.1.0 * * @param bool $state The state for debug mode. * * @return bool */ public function debug( bool $state ): bool { $config = $this->config; $config->set( 'page_cache.debug', $state ); $config->save(); return (bool) $config->get( 'page_cache.debug' ); } }