函数文档

wp_caption_input_textarea()

💡 云策文档标注

概述

wp_caption_input_textarea() 函数用于输出一个文本区域元素,用于输入附件标题。它接受一个 WP_Post 对象作为参数,并返回对应的 HTML 标记。

关键要点

  • 函数输出一个 textarea 元素,用于编辑附件的标题(post_excerpt)。
  • 参数 $edit_post 是必需的,类型为 WP_Post 对象,表示要编辑的附件。
  • 返回值是 textarea 元素的 HTML 字符串,包含已转义的 post_excerpt 内容。
  • 该函数自 WordPress 3.4.0 版本引入,主要用于 get_attachment_fields_to_edit() 函数中。

代码示例

function wp_caption_input_textarea( $edit_post ) {
    // Post data is already escaped.
    $name = "attachments[{$edit_post->ID}][post_excerpt]";

    return '<textarea name="' . $name . '" id="attachments-' . $edit_post->ID . '-post_excerpt">' . $edit_post->post_excerpt . '</textarea>';
}

📄 原文内容

Outputs a textarea element for inputting an attachment caption.

Parameters

$edit_postWP_Postrequired
Attachment WP_Post object.

Return

string HTML markup for the textarea element.

Source

function wp_caption_input_textarea( $edit_post ) {
	// Post data is already escaped.
	$name = "attachments[{$edit_post->ID}][post_excerpt]";

	return '<textarea name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
}

Changelog

Version Description
3.4.0 Introduced.