On this page
wp_encode_emoji( string $content ): string
Converts emoji characters to their equivalent HTML entity.
Description
This allows us to store emoji in a DB using the utf8 character set.
Parameters
$contentstring Required-
The content to encode.
Return
string The encoded content.
Source
File: wp-includes/formatting.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| _wp_emoji_list() wp-includes/formatting.php | Returns arrays of emoji data. |
Used By
| Used By | Description |
|---|---|
| wp_staticize_emoji() wp-includes/formatting.php | Converts emoji to a static img element. |
| sanitize_option() wp-includes/formatting.php | Sanitizes various option values based on the nature of the option. |
| wp_insert_post() wp-includes/post.php | Inserts or update a post. |
Changelog
| Version | Description |
|---|---|
| 4.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_encode_emoji