WordPress开发者和主题制作者的搜索引擎



wp_encode_emoji ›

Since4.2.0
已弃用n/a
wp_encode_emoji ( $content )
参数:
  • (string) $content The content to encode.
    Required: Yes
返回:
  • (string) The encoded content.
定义在:
文档:

Convert emoji characters to their equivalent HTML entity.

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



源码

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

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

	return $content;
}