convert_invalid_entities() WordPress Function
The convert_invalid_entities() function is used to convert invalid HTML entities into valid ones. This is useful when you want to display content that may contain invalid HTML entities, such as when you're displaying user-generated content.
convert_invalid_entities( string $content ) #
Converts invalid Unicode references range to valid range.
Contents
Parameters
- $content
(string)(Required)String with entities that need converting.
Return
(string) Converted string.
Source
File: wp-includes/formatting.php
function convert_invalid_entities( $content ) { $wp_htmltranswinuni = array( '€' => '€', // The Euro sign. '' => '', '‚' => '‚', // These are Windows CP1252 specific characters. 'ƒ' => 'ƒ', // They would look weird on non-Windows browsers. '„' => '„', '…' => '…', '†' => '†', '‡' => '‡', 'ˆ' => 'ˆ', '‰' => '‰', 'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ', '' => '', 'Ž' => 'Ž', '' => '', '' => '', '‘' => '‘', '’' => '’', '“' => '“', '”' => '”', '•' => '•', '–' => '–', '—' => '—', '˜' => '˜', '™' => '™', 'š' => 'š', '›' => '›', 'œ' => 'œ', '' => '', 'ž' => 'ž', 'Ÿ' => 'Ÿ', ); if ( strpos( $content, '' ) !== false ) { $content = strtr( $content, $wp_htmltranswinuni ); } return $content; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.3.0 | Introduced. |