_wp_footnotes_kses_init()
云策文档标注
概述
_wp_footnotes_kses_init() 函数用于根据当前用户的权限,动态注册或移除脚注元字段的过滤器。它检查用户是否具有 unfiltered_html 能力,以决定是否应用 KSES 过滤。
关键要点
- 函数首先调用 _wp_footnotes_remove_filters() 移除现有过滤器
- 如果当前用户没有 unfiltered_html 能力,则调用 _wp_footnotes_kses_init_filters() 添加过滤器
- 这确保了脚注内容的安全性,防止未授权用户插入不安全 HTML
代码示例
function _wp_footnotes_kses_init() {
_wp_footnotes_remove_filters();
if ( ! current_user_can( 'unfiltered_html' ) ) {
_wp_footnotes_kses_init_filters();
}
}注意事项
- 此函数在 WordPress 6.3.2 版本中引入
- 相关函数包括 _wp_footnotes_remove_filters() 和 _wp_footnotes_kses_init_filters(),用于管理过滤器
- 依赖 current_user_can() 函数检查用户能力
原文内容
Registers the filter of footnotes meta field if the user does not have unfiltered_html capability.
Source
function _wp_footnotes_kses_init() {
_wp_footnotes_remove_filters();
if ( ! current_user_can( 'unfiltered_html' ) ) {
_wp_footnotes_kses_init_filters();
}
}
Changelog
| Version | Description |
|---|---|
| 6.3.2 | Introduced. |