wpautop()
wpautop( string $pee, bool $br = true ) 用段落元素替换双换行符。 Re…
wpautop( string $pee, bool $br = true )
用段落元素替换双换行符。
Replaces double line-breaks with paragraph elements.
用段落元素替换双换行符。
Replaces double line-breaks with paragraph elements.
目录锚点:#说明#参数#源码#笔记
说明(Description)
一组正则表达式替换,用于标识用换行符格式化的文本,并用HTML段落标记替换双换行符。除非$br设置为“0”或“false”,否则转换后剩余的换行符将变为“标记”。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $pee | (string) | 必须格式化的文本。 |
| $br | (bool) | 如果设置,这将转换分段后所有剩余的换行符。 |
源码(Source)
/**
* Replaces double line-breaks with paragraph elements.
*
* A group of regex replaces used to identify text formatted with newlines and
* replace double line-breaks with HTML paragraph tags. The remaining line-breaks
* after conversion become > tags, unless $br is set to '0' or 'false'.
*
* @since 0.71
*
* @param string $pee The text which has to be formatted.
* @param bool $br Optional. If set, this will convert all remaining line-breaks
* after paragraphing. Default true.
* @return string Text which has been converted into correct paragraph tags.
*/
function wpautop( $pee, $br = true ) {
$pre_tags = array();
if ( trim($pee) === '' )
return '';
// Just to make things a little easier, pad the end.
$pee = $pee . "
";
/*
* Pre tags shouldn't be touched by autop.
* Replace pre tags with placeholders and bring them back after autop.
*/
if ( strpos($pee, '| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 0.71 | wp-includes/formatting.php | 19 | 10 |
笔记(Notes)
如果wpauto在不需要的地方添加段落时遇到问题,可以在页面内容中禁用它,方法是在子主题中添加以下内容函数.php文件:
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

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