1. 首页
  2. WordPress 函数手册

wp_kses_normalize_entities()

wp_kses_normalize_entities( string $string )

转换和修复HTML实体。
Converts and fixes HTML entities.

目录锚点:#说明#参数#源码


说明(Description)

此函数用于规范化HTML实体。它将把AT&T转换为正确的AT&T、:to:、&&xyzy;到xyzy;等等。


参数(Parameters)

参数 类型 说明
$string (string) 规范化实体的内容。

源码(Source)

/**
 * Converts and fixes HTML entities.
 *
 * This function normalizes HTML entities. It will convert `AT&T` to the correct
 * `AT&T`, `:` to `:`, `&#XYZZY;` to `&#XYZZY;` and so on.
 *
 * @since 1.0.0
 *
 * @param string $string Content to normalize entities
 * @return string Content with normalized entities
 */
function wp_kses_normalize_entities($string) {
	// Disarm all entities by converting & to &
	$string = str_replace('&', '&', $string);

	// Change back the allowed entities in our entity whitelist
	$string = preg_replace_callback('/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $string);
	$string = preg_replace_callback('/&#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string);
	$string = preg_replace_callback('/&#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string);

	return $string;
}
更新版本 源码位置 使用 被使用
1.0.0 wp-includes/kses.php 4 14

wp_kses_normalize_entities() 为WP2原创文章,链接:https://www.wp2.cn/functions/wp_kses_normalize_entities/