返回介绍

wp_kses_allowed_html()

发布于 2017-09-11 12:18:59 字数 2939 浏览 1054 评论 0 收藏 0

wp_kses_allowed_html( string $context = '' )

Return a list of allowed tags and attributes for a given context.


description


参数

$context

(string) (Optional) The context for which to retrieve tags. Allowed values are post, strip, data,entities, or the name of a field filter such as pre_user_description.

Default value: ''


返回值

(array) List of allowed tags and their allowed attributes.


源代码

File: wp-includes/kses.php

function wp_kses_allowed_html( $context = '' ) {
	global $allowedposttags, $allowedtags, $allowedentitynames;

	if ( is_array( $context ) ) {
		/**
		 * Filters HTML elements allowed for a given context.
		 *
		 * @since 3.5.0
		 *
		 * @param string $tags    Allowed tags, attributes, and/or entities.
		 * @param string $context Context to judge allowed tags by. Allowed values are 'post',
		 *                        'data', 'strip', 'entities', 'explicit', or the name of a filter.
		 */
		return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' );
	}

	switch ( $context ) {
		case 'post':
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );

		case 'user_description':
		case 'pre_user_description':
			$tags = $allowedtags;
			$tags['a']['rel'] = true;
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $tags, $context );

		case 'strip':
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', array(), $context );

		case 'entities':
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context);

		case 'data':
		default:
			/** This filter is documented in wp-includes/kses.php */
			return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );
	}
}

更新日志

Versiondescription
3.5.0Introduced.

相关函数

Uses

  • wp-includes/kses.php: wp_kses_allowed_html
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-includes/kses.php: wp_kses_one_attr()
  • wp-includes/kses.php: wp_kses_attr()
  • wp-includes/kses.php: wp_kses_split2()
  • wp-includes/media.php: gallery_shortcode()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文