wpseek.com
				A WordPress-centric search engine for devs and theme authors
			convert_smilies › WordPress Function
Since0.71
Deprecatedn/a
› convert_smilies ( $text )
| Parameters: | 
 | 
| Returns: | 
 | 
| Defined at: | 
 | 
| Codex: | 
Converts text equivalent of smilies to images.
Will only convert smilies if the option 'use_smilies' is true and the global used in the function isn't empty.Related Functions: convert_invalid_entities, convert_chars, convert_to_screen, count_users, wp_count_sites
	Source
function convert_smilies( $text ) {
	global $wp_smiliessearch;
	if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) {
		// Return default text.
		return $text;
	}
	// HTML loop taken from texturize function, could possible be consolidated.
	$textarr = preg_split( '/(<[^>]*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between.
	if ( false === $textarr ) {
		// Return default text.
		return $text;
	}
	// Loop stuff.
	$stop   = count( $textarr );
	$output = '';
	// Ignore processing of specific tags.
	$tags_to_ignore       = 'code|pre|style|script|textarea';
	$ignore_block_element = '';
	for ( $i = 0; $i < $stop; $i++ ) {
		$content = $textarr[ $i ];
		// If we're in an ignore block, wait until we find its closing tag.
		if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) {
			$ignore_block_element = $matches[1];
		}
		// If it's not a tag and not in ignore block.
		if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) {
			$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
		}
		// Did we exit ignore block?
		if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) {
			$ignore_block_element = '';
		}
		$output .= $content;
	}
	return $output;
}