钩子文档

enable_loading_advanced_cache_dropin

💡 云策文档标注

概述

enable_loading_advanced_cache_dropin 是一个 WordPress 过滤器,用于控制是否加载 advanced-cache.php 文件。它主要设计用于非 Web 运行时环境,允许插件在加载前干预此过程。

关键要点

  • 此过滤器决定是否启用 advanced-cache.php 的加载,如果返回 false,则永远不会加载该文件。
  • 它运行在插件使用之前,适用于非 Web 运行时的场景。
  • 参数 $enable_advanced_cache 是一个布尔值,默认为 true,表示启用加载。
  • 在 WordPress 4.6.0 版本中引入。

代码示例

if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {

注意事项

  • 此过滤器与 WP_CACHE 常量和文件存在性检查结合使用,确保仅在条件满足时加载 advanced-cache.php。
  • 在 WP_Site_Health::check_for_page_caching() 中用于检查页面缓存是否启用。

📄 原文内容

Filters whether to enable loading of the advanced-cache.php drop-in.

Description

This filter runs before it can be used by plugins. It is designed for non-web run-times. If false is returned, advanced-cache.php will never be loaded.

Parameters

$enable_advanced_cachebool
Whether to enable loading advanced-cache.php (if present).
Default true.

Source

if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {

Changelog

Version Description
4.6.0 Introduced.