install_themes_upload()
概述
install_themes_upload() 函数用于在 WordPress 后台显示一个上传主题 ZIP 文件的上传表单。该函数是 WordPress 主题安装功能的一部分,面向开发者提供主题上传界面的实现。
关键要点
- 函数 install_themes_upload() 显示一个表单,允许用户通过 ZIP 文件上传主题。
- 该函数在 WordPress 2.8.0 版本中引入,是主题管理功能的核心组件。
- 相关函数包括 submit_button()、wp_nonce_field()、self_admin_url()、_e()、_x() 和 esc_url() 等,用于表单提交、安全验证、URL 处理和本地化。
Displays a form to upload themes from zip files.
Source
function install_themes_upload() {
?>
<p class="install-help"></p>
<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo esc_url( self_admin_url( 'update.php?action=upload-theme' ) ); ?>">
<label class="screen-reader-text" for="themezip">
</label>
<input type="file" id="themezip" name="themezip" accept=".zip" />
</form>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-admin/includes/theme-install.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/theme-install.php#L195">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/theme-install.php#L195-L210">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).
wp_nonce_field()wp-includes/functions.php
Retrieves or display nonce hidden field for forms.
self_admin_url()wp-includes/link-template.php
Retrieves the URL to the admin area for either the current site or the network depending on context.
_e()wp-includes/l10n.php
Displays translated text.
_x()wp-includes/l10n.php
Retrieves translated string with gettext context.
esc_url()wp-includes/formatting.php
Checks and cleans a URL.
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |