wp_use_widgets_block_editor()
云策文档标注
概述
wp_use_widgets_block_editor() 函数用于确定是否使用区块编辑器来管理小工具。默认返回 true,除非主题移除了对 widgets-block-editor 的支持或插件过滤了此函数的返回值。
关键要点
- 函数返回布尔值,指示是否启用小工具的区块编辑器管理。
- 默认行为基于主题对 widgets-block-editor 的支持状态。
- 可通过 apply_filters('use_widgets_block_editor', $use_widgets_block_editor) 钩子过滤返回值。
- 函数自 WordPress 5.8.0 版本引入。
代码示例
function wp_use_widgets_block_editor() {
/**
* Filters whether to use the block editor to manage widgets.
*
* @since 5.8.0
*
* @param bool $use_widgets_block_editor Whether to use the block editor to manage widgets.
*/
return apply_filters(
'use_widgets_block_editor',
get_theme_support( 'widgets-block-editor' )
);
}
原文内容
Determines whether or not to use the block editor to manage widgets.
Description
Defaults to true unless a theme has removed support for widgets-block-editor or a plugin has filtered the return value of this function.
Source
function wp_use_widgets_block_editor() {
/**
* Filters whether to use the block editor to manage widgets.
*
* @since 5.8.0
*
* @param bool $use_widgets_block_editor Whether to use the block editor to manage widgets.
*/
return apply_filters(
'use_widgets_block_editor',
get_theme_support( 'widgets-block-editor' )
);
}
Hooks
- apply_filters( ‘use_widgets_block_editor’, bool $use_widgets_block_editor )
-
Filters whether to use the block editor to manage widgets.
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |