钩子文档

force_filtered_html_on_import

💡 云策文档标注

概述

force_filtered_html_on_import 是一个 WordPress 过滤器钩子,用于控制在导入数据时是否强制通过 kses 进行过滤。它主要用于多站点环境,以增强安全性。

关键要点

  • 此钩子允许开发者覆盖默认行为,决定是否在导入过程中强制使用 kses 过滤数据。
  • 默认情况下,在多站点中,超级管理员可能协助不受信任的用户,因此数据会通过 kses 过滤。
  • 参数 $force 是一个布尔值,默认为 false,表示不强制过滤;设置为 true 可启用强制过滤。

代码示例

if ( apply_filters( 'force_filtered_html_on_import', false ) ) {
    // 强制过滤逻辑
}

注意事项

此钩子从 WordPress 3.1.0 版本开始引入,主要用于多站点场景,以处理潜在的安全风险。


📄 原文内容

Filters whether to filter imported data through kses on import.

Description

Multisite uses this hook to filter all data through kses by default, as a super administrator may be assisting an untrusted user.

Parameters

$forcebool
Whether to force data to be filtered through kses. Default false.

Source

if ( apply_filters( 'force_filtered_html_on_import', false ) ) {

Changelog

Version Description
3.1.0 Introduced.