wp_kses_decode_entities() WordPress Function

The wp_kses_decode_entities() function is used to decode HTML entities in a string. This function is similar to the html_entity_decode() function in PHP, but it is specifically designed for use with the WordPress platform. This function is useful for ensuring that strings are properly decoded when they are passed through the WordPress security system.

wp_kses_decode_entities( string $string ) #

Converts all numeric HTML entities to their named counterparts.


Description

This function decodes numeric HTML entities (A and A). It doesn’t do anything with named entities like ä, but we don’t need them in the allowed URL protocols system anyway.


Top ↑

Parameters

$string

(string)(Required)Content to change entities.


Top ↑

Return

(string) Content after decoded entities.


Top ↑

Source

File: wp-includes/kses.php

function wp_kses_decode_entities( $string ) {
	$string = preg_replace_callback( '/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $string );
	$string = preg_replace_callback( '/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $string );

	return $string;
}

Top ↑

Changelog

Changelog
VersionDescription
1.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.