函数文档

_cleanup_image_add_caption()

💡 云策文档标注

概述

_cleanup_image_add_caption() 是一个私有函数,用于在 image_add_caption() 中作为 preg_replace 回调,清理 HTML 中的换行符和制表符。

关键要点

  • 这是一个私有函数,仅在 image_add_caption() 内部使用
  • 主要功能是移除 HTML 标签内的换行符和制表符,替换为空格
  • 接受一个数组参数 $matches,返回清理后的 HTML 字符串
  • 自 WordPress 3.4.0 版本引入

代码示例

function _cleanup_image_add_caption( $matches ) {
    // Remove any line breaks from inside the tags.
    return preg_replace( '/[rnt]+/', ' ', $matches[0] );
}

📄 原文内容

Private preg_replace callback used in image_add_caption() .

Parameters

$matchesarrayrequired
Single regex match.

Return

string Cleaned up HTML for caption.

Source

function _cleanup_image_add_caption( $matches ) {
	// Remove any line breaks from inside the tags.
	return preg_replace( '/[rnt]+/', ' ', $matches[0] );
}

Changelog

Version Description
3.4.0 Introduced.