Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_encode_emoji ›

Da4.2.0
Deprecaton/a
wp_encode_emoji ( $content )
Parametri:
  • (string) $content The content to encode.
    Richiesto:
Ritorna:
  • (string) The encoded content.
Definito a:
Codex:

Convert emoji characters to their equivalent HTML entity.

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



Sorgenti

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