钩子文档

load_default_widgets

💡 云策文档标注

概述

load_default_widgets 是一个 WordPress 过滤器,用于控制是否加载 Widgets 库。通过返回 false 值,可以阻止 Widgets 库的加载。

关键要点

  • 这是一个过滤器,用于决定是否加载 Widgets 库。
  • 返回 false 值可以阻止 Widgets 库加载。
  • 默认值为 true,表示默认加载 Widgets 库。
  • 在 wp_maybe_load_widgets() 函数中使用。
  • 从 WordPress 2.8.0 版本开始引入。

代码示例

if ( ! apply_filters( 'load_default_widgets', true ) ) {
    // 代码逻辑
}

📄 原文内容

Filters whether to load the Widgets library.

Description

Returning a falsey value from the filter will effectively short-circuit the Widgets library from loading.

Parameters

$wp_maybe_load_widgetsbool
Whether to load the Widgets library.
Default true.

Source

if ( ! apply_filters( 'load_default_widgets', true ) ) {

Changelog

Version Description
2.8.0 Introduced.