函数文档

iframe_footer()

💡 云策文档标注

概述

iframe_footer() 是一个用于 Thickbox 的通用 iframe 页脚函数,主要作用是隐藏 iframe 页面的页脚输出,同时确保相关钩子(如 admin_footer)仍能执行以输出必要的 JavaScript 或内容。

关键要点

  • 函数 iframe_footer() 用于 Thickbox 的 iframe 页面,隐藏页脚输出但运行钩子。
  • 使用全局变量 $hook_suffix 来支持特定后缀的钩子,如 admin_print_footer_scripts-{$hook_suffix}。
  • 相关钩子包括 do_action('admin_footer')、do_action('admin_print_footer_scripts') 和 do_action("admin_print_footer_scripts-{$hook_suffix}")。
  • 函数在 WordPress 2.7.0 版本中引入,被 install_theme_information() 和 install_plugin_information() 等函数使用。

代码示例

Source function iframe_footer() {
    /*
     * We're going to hide any footer output on iFrame pages,
     * but run the hooks anyway since they output JavaScript
     * or other needed content.
     */

    /**
     * @global string $hook_suffix
     */
    global $hook_suffix;
    ?>
    // 此处省略了 HTML 输出部分,实际函数可能包含更多代码
    <?php
}

📄 原文内容

Generic Iframe footer for use with Thickbox.

Source

function iframe_footer() {
/*
* We're going to hide any footer output on iFrame pages,
* but run the hooks anyway since they output JavaScript
* or other needed content.
*/

/**
* @global string $hook_suffix
*/
global $hook_suffix;
?>
<div class="hidden">

</div>
<script type="text/javascript">if(typeof wpOnload==='function')wpOnload();</script>
</body>
</html>
</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#L2205">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/template.php#L2205-L2233">View on GitHub</a></p></section>
<section class="wp-block-wporg-code-reference-hooks"><h2 id="hooks" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#hooks">Hooks</a></h2> <dl><dt class="wp-block-wporg-code-reference-title has-normal-font-size"><a href="https://developer.wordpress.org/reference/hooks/admin_footer/"><span class="hook-func">do_action</span>( ‘admin_footer’, <nobr><span class="arg-type">string</span> <span class="arg-name">$data</span></nobr> )</a></dt><dd><p>Prints scripts or data before the default footer scripts.</p>
</dd><dt class="wp-block-wporg-code-reference-title has-normal-font-size"><a href="https://developer.wordpress.org/reference/hooks/admin_print_footer_scripts/"><span class="hook-func">do_action</span>( ‘admin_print_footer_scripts’ )</a></dt><dd><p>Prints any scripts and data queued for the footer.</p>
</dd><dt class="wp-block-wporg-code-reference-title has-normal-font-size"><a href="https://developer.wordpress.org/reference/hooks/admin_print_footer_scripts-hook_suffix/"><span class="hook-func">do_action</span>( “admin_print_footer_scripts-{$hook_suffix}” )</a></dt><dd><p>Prints scripts and data queued for the footer.</p>
</dd></dl></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/do_action/">do_action()</a><code>wp-includes/plugin.php

Calls the callback functions that have been added to an action hook.

Used by Description
install_theme_information()wp-admin/includes/theme-install.php

Displays theme information in dialog box form.

install_plugin_information()wp-admin/includes/plugin-install.php

Displays plugin information in dialog box form.

Changelog

Version Description
2.7.0 Introduced.