wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_encode_emoji › WordPress Function

Od4.2.0
Przestarzałyn/a
wp_encode_emoji ( $content )
Parametry:
  • (string) $content The content to encode.
    Wymagane: Tak
Powrót:
  • (string) The encoded content.
Zdefiniowane na:
Codex:

Converts emoji characters to their equivalent HTML entity.

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


Źródło

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