函数文档

find_posts_div()

💡 云策文档标注

概述

find_posts_div() 函数用于在媒体列表屏幕中输出模态窗口,以便将媒体附加到文章或页面。它接受一个可选参数来控制操作行为。

关键要点

  • 函数输出一个模态窗口,用于在媒体列表界面中附加媒体到文章或页面。
  • 参数 $found_action 是可选的字符串,用于设置 'found_action' 输入字段的值,默认为空字符串。
  • 函数内部包含 HTML 和 PHP 代码,用于生成模态窗口的界面元素。
  • 相关函数包括 submit_button()、esc_attr_e()、wp_nonce_field() 等,用于处理按钮、转义和非ce字段。
  • 该函数自 WordPress 2.7.0 版本引入,无后续变更记录。

📄 原文内容

Outputs the modal window used for attaching media to posts or pages in the media-listing screen.

Parameters

$found_actionstringoptional
The value of the 'found_action' input field. Default empty string.

Source

function find_posts_div( $found_action = '' ) {
?>
<div id="find-posts" class="find-box" style="display: none;">
<div id="find-posts-head" class="find-box-head">

<button type="button" id="find-posts-close"><span class="screen-reader-text">

</span></button>
</div>
<div class="find-box-inside">
<div class="find-box-search">

<input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" />

<input type="hidden" name="affected" id="affected" value="" />

<label class="screen-reader-text" for="find-posts-input">

</label>
<input type="text" id="find-posts-input" name="ps" value="" />
<span class="spinner"></span>
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
<div class="clear"></div>
</div>
<div id="find-posts-response"></div>
</div>
<div class="find-box-buttons">

<div class="clear"></div>
</div>
</div>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-admin/includes/template.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/template.php#L2027">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/template.php#L2027-L2065">View on GitHub</a></p></section>

<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/submit_button/">submit_button()</a><code>wp-admin/includes/template.php

Echoes a submit button, with provided text and appropriate class(es).

esc_attr_e()wp-includes/l10n.php

Displays translated text that has been escaped for safe use in an attribute.

wp_nonce_field()wp-includes/functions.php

Retrieves or display nonce hidden field for forms.

_e()wp-includes/l10n.php

Displays translated text.

__()wp-includes/l10n.php

Retrieves the translation of $text.

esc_attr()wp-includes/formatting.php

Escaping for HTML attributes.

Show 3 moreShow less

Changelog

Version Description
2.7.0 Introduced.