函数文档

wp_kses_post_deep()

💡 云策文档标注

概述

wp_kses_post_deep() 是一个 WordPress 函数,用于递归遍历数组、对象或标量值,并基于 wp_kses_post() 函数对内容进行 HTML 标签过滤,确保符合文章内容的允许标签规则。

关键要点

  • 函数递归处理输入数据,包括数组、对象或标量值。
  • 内部调用 map_deep() 函数,将 wp_kses_post() 应用于所有非可迭代元素。
  • 返回过滤后的内容,保持原始数据结构。
  • 自 WordPress 4.4.2 版本引入。

代码示例

function wp_kses_post_deep( $data ) {
    return map_deep( $data, 'wp_kses_post' );
}

📄 原文内容

Navigates through an array, object, or scalar, and sanitizes content for allowed HTML tags for post content.

Description

See also

Parameters

$datamixedrequired
The array, object, or scalar value to inspect.

Return

mixed The filtered content.

Source

function wp_kses_post_deep( $data ) {
	return map_deep( $data, 'wp_kses_post' );
}

Changelog

Version Description
4.4.2 Introduced.