函数文档

kses_init()

💡 云策文档标注

概述

kses_init() 函数用于设置 KSES 过滤器,以处理输入表单内容。它首先移除所有 KSES 过滤器,然后根据当前用户的权限决定是否重新添加这些过滤器。

关键要点

  • 函数首先调用 kses_remove_filters() 移除所有 KSES 过滤器。
  • 如果当前用户没有 unfiltered_html 权限,则调用 kses_init_filters() 添加 KSES 过滤器。
  • 这确保了只有具有适当权限的用户才能绕过内容过滤。

代码示例

function kses_init() {
	kses_remove_filters();

	if ( ! current_user_can( 'unfiltered_html' ) ) {
		kses_init_filters();
	}
}

📄 原文内容

Sets up most of the KSES filters for input form content.

Description

First removes all of the KSES filters in case the current user does not need to have KSES filter the content. If the user does not have unfiltered_html capability, then KSES filters are added.

Source

function kses_init() {
	kses_remove_filters();

	if ( ! current_user_can( 'unfiltered_html' ) ) {
		kses_init_filters();
	}
}

Changelog

Version Description
2.0.0 Introduced.