wp_encode_emoji( string $content )
Convert emoji characters to their equivalent HTML entity.
Description
This allows us to store emoji in a DB using the utf8 character set.
Parameters
- $content
-
(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' );
$compat = version_compare( phpversion(), '5.4', '<' );
foreach ( $emoji as $emojum ) {
if ( $compat ) {
$emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
} else {
$emoji_char = html_entity_decode( $emojum );
}
if ( false !== strpos( $content, $emoji_char ) ) {
$content = preg_replace( "/$emoji_char/", $emojum, $content );
}
}
return $content;
}
Changelog
Version | Description |
---|---|
WP-4.2.0 | Introduced. |