wp_encode_emoji() – Converts emoji characters to their equivalent HTML entity.

You appear to be a bot. Output may be restricted

Description

Converts emoji characters to their equivalent HTML entity.

This allows us to store emoji in a DB using the utf8 character set.

Usage

$string = wp_encode_emoji( $content );

Parameters

$content
( string ) required – The content to encode.

Returns

string The encoded content.

Source

File name: wordpress/wp-includes/formatting.php
Lines:

1 to 12 of 12
function wp_encode_emoji( $content ) {
  $emoji = _wp_emoji_list( 'partials' );

  foreach ( $emoji as $emojum ) {
    $emoji_char = html_entity_decode( $emojum );
    if ( str_contains( $content, $emoji_char ) ) {
      $content = preg_replace( "/$emoji_char/", $emojum, $content );
    }
  }

  return $content;
}
 

 View on GitHub View on Trac