WordPress at a glance

wp_encode_emoji() WP 1.0

Convert emoji characters to their equivalent HTML entity.

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

Is the basis for: wp_staticize_emoji()
✈ 1 time = 0.00028s = fast | 50000 times = 8.13s = fast

No Hooks.

Return

String. The encoded content.

Usage

wp_encode_emoji( $content );
$content(string) (required)
The content to encode.

Code of wp_encode_emoji: wp-includes/formatting.php VER 4.9.8

<?php
function wp_encode_emoji( $content ) {
	$emoji = _wp_emoji_list( 'partials' );

	foreach ( $emoji as $emojum ) {
		if ( version_compare( phpversion(), '5.4', '<' ) ) {
			$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;
}

Related Functions

From tag: emoji

No comments
    Hello, !     Log In . Register