函数文档

_autop_newline_preservation_helper()

💡 云策文档标注

概述

_autop_newline_preservation_helper() 是 WordPress 中用于辅助 wpautop() 函数保留换行符的内部函数。它通过移除字符串中的换行符来帮助处理文本格式。

关键要点

  • 函数用途:作为 wpautop() 的辅助函数,用于在文本处理中保留换行符。
  • 参数:接受一个 $matches 数组,这是 preg_replace_callback 函数提供的匹配数组。
  • 返回值:返回一个字符串,其中移除了所有换行符。
  • 引入版本:从 WordPress 3.1.0 版本开始引入。

代码示例

function _autop_newline_preservation_helper( $matches ) {
	return str_replace( "n", '', $matches[0] );
}

📄 原文内容

Newline preservation help function for wpautop() .

Parameters

$matchesarrayrequired
preg_replace_callback matches array

Return

string

Source

function _autop_newline_preservation_helper( $matches ) {
	return str_replace( "n", '<WPPreserveNewline />', $matches[0] );
}

Changelog

Version Description
3.1.0 Introduced.