返回介绍

wp_import_upload_form()

发布于 2017-09-11 12:12:45 字数 2930 浏览 960 评论 0 收藏 0

wp_import_upload_form( string $action )

Outputs the form used by the importers to accept the data to be imported


description


参数

$action

(string) (Required) The action attribute for the form.


源代码

File: wp-admin/includes/template.php

function wp_import_upload_form( $action ) {

	/**
	 * Filters the maximum allowed upload size for import files.
	 *
	 * @since 2.3.0
	 *
	 * @see wp_max_upload_size()
	 *
	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
	 */
	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
	$size = size_format( $bytes );
	$upload_dir = wp_upload_dir();
	if ( ! empty( $upload_dir['error'] ) ) :
		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
	else :
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
<p>
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
</p>
<?php submit_button( __('Upload file and import'), 'primary' ); ?>
</form>
<?php
	endif;
}

更新日志

Versiondescription
2.0.0Introduced.

相关函数

Uses

  • wp-admin/includes/template.php: submit_button()
  • wp-admin/includes/template.php: import_upload_size_limit
  • wp-includes/l10n.php: _e()
  • wp-includes/l10n.php: __()
  • wp-includes/formatting.php: esc_url()
  • wp-includes/functions.php: wp_upload_dir()
  • wp-includes/functions.php: wp_nonce_url()
  • wp-includes/functions.php: size_format()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/media.php: wp_max_upload_size()
  • Show 5 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文