wp_encode_emoji() WordPress Function
The wp_encode_emoji() function is used to convert Unicode characters to their corresponding HTML entities. This is necessary for displaying Emoji characters on websites that do not support Unicode characters.
wp_encode_emoji( string $content ) #
Converts emoji characters to their equivalent HTML entity.
Description
This allows us to store emoji in a DB using the utf8 character set.
Parameters
- $content
(string)(Required)The content to encode.
Return
(string) The encoded content.
Source
File: wp-includes/formatting.php
function wp_encode_emoji( $content ) {
$emoji = _wp_emoji_list( 'partials' );
foreach ( $emoji as $emojum ) {
$emoji_char = html_entity_decode( $emojum );
if ( false !== strpos( $content, $emoji_char ) ) {
$content = preg_replace( "/$emoji_char/", $emojum, $content );
}
}
return $content;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.2.0 | Introduced. |