wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



wp_encode_emoji › WordPress Function

Depuis4.2.0
Dépréciéen/a
wp_encode_emoji ( $content )
Paramètres:
  • (string) $content The content to encode.
    Requis: Oui
Retourne:
  • (string) The encoded content.
Défini(e) dans:
Codex:

Converts emoji characters to their equivalent HTML entity.

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


Source

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;
}