convert_smilies()
convert_smilies( string $text ) 将等同于smilies的文本转换为图像。Con…
convert_smilies( string $text )
将等同于smilies的文本转换为图像。
Convert text equivalent of smilies to images.
将等同于smilies的文本转换为图像。
Convert text equivalent of smilies to images.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
仅当选项“use_smilies”为true且函数中使用的全局不为空时,才会转换smilies。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $text | (string) | 必需 | 从文本转换笑脸的内容。 |
返回(Return)
(string)转换后的内容,文本smilies替换为图像。
源码(Source)
/**
* Convert 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.
*
* @since 0.71
*
* @global string|array $wp_smiliessearch
*
* @param string $text Content to convert smilies from text.
* @return string Converted content with text smilies replaced with images.
*/
function convert_smilies( $text ) {
global $wp_smiliessearch;
$output = '';
if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
// 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
$stop = count( $textarr );// loop stuff
// Ignore proessing 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" &&="">' == $content ) {
$ignore_block_element = '';
}
$output .= $content;
}
} else {
// return default text.
$output = $text;
}
return $output;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 0.71 | wp-includes/formatting.php:3339 | 0 | 1 function |
笔记(Notes)
显示带有转换的笑脸的文本
使插件生成的内容解析图释:
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!