返回介绍

media_upload_form()

发布于 2017-09-11 01:52:25 字数 5209 浏览 1268 评论 0 收藏 0

media_upload_form( array $errors = null )

Outputs the legacy media upload form.


description


参数

$errors

(array) (Optional)

Default value: null


源代码

File: wp-admin/includes/media.php

function media_upload_form( $errors = null ) {
	global $type, $tab, $is_IE, $is_opera;

	if ( ! _device_can_upload() ) {
		echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ) . '</p>';
		return;
	}

	$upload_action_url = admin_url('async-upload.php');
	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
	$_type = isset($type) ? $type : '';
	$_tab = isset($tab) ? $tab : '';

	$max_upload_size = wp_max_upload_size();
	if ( ! $max_upload_size ) {
		$max_upload_size = 0;
	}
?>

<div id="media-upload-notice"><?php

	if (isset($errors['upload_notice']) )
		echo $errors['upload_notice'];

?></div>
<div id="media-upload-error"><?php

	if (isset($errors['upload_error']) && is_wp_error($errors['upload_error']))
		echo $errors['upload_error']->get_error_message();

?></div>
<?php
if ( is_multisite() && !is_upload_space_available() ) {
	/**
	 * Fires when an upload will exceed the defined upload space quota for a network site.
	 *
	 * @since 3.5.0
	 */
	do_action( 'upload_ui_over_quota' );
	return;
}

/**
 * Fires just before the legacy (pre-3.5.0) upload interface is loaded.
 *
 * @since 2.6.0
 */
do_action( 'pre-upload-ui' );

$post_params = array(
	"post_id" => $post_id,
	"_wpnonce" => wp_create_nonce('media-form'),
	"type" => $_type,
	"tab" => $_tab,
	"short" => "1",
);

/**
 * Filters the media upload post parameters.
 *
 * @since 3.1.0 As 'swfupload_post_params'
 * @since 3.3.0
 *
 * @param array $post_params An array of media upload parameters used by Plupload.
 */
$post_params = apply_filters( 'upload_post_params', $post_params );

$plupload_init = array(
	'runtimes'            => 'html5,flash,silverlight,html4',
	'browse_button'       => 'plupload-browse-button',
	'container'           => 'plupload-upload-ui',
	'drop_element'        => 'drag-drop-area',
	'file_data_name'      => 'async-upload',
	'url'                 => $upload_action_url,
	'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
	'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
	'filters' => array(
		'max_file_size'   => $max_upload_size . 'b',
	),
	'multipart_params'    => $post_params,
);

// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
// when enabled. See

更新日志

Versiondescription
2.5.0Introduced.

相关函数

Uses

  • wp-includes/functions.php: wp_json_encode()
  • wp-admin/includes/template.php: submit_button()
  • wp-admin/includes/media.php: post-upload-ui
  • wp-admin/includes/media.php: upload_ui_over_quota
  • wp-admin/includes/media.php: pre-upload-ui
  • wp-admin/includes/media.php: upload_post_params
  • wp-admin/includes/media.php: plupload_init
  • wp-admin/includes/media.php: pre-plupload-upload-ui
  • wp-admin/includes/media.php: post-plupload-upload-ui
  • wp-admin/includes/media.php: pre-html-upload-ui
  • wp-admin/includes/media.php: post-html-upload-ui
  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: _e()
  • wp-includes/l10n.php: _ex()
  • wp-includes/l10n.php: esc_attr_e()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/pluggable.php: wp_create_nonce()
  • wp-includes/vars.php: wp_is_mobile()
  • wp-includes/load.php: is_multisite()
  • wp-includes/functions.php: _device_can_upload()
  • wp-includes/functions.php: absint()
  • wp-includes/functions.php: size_format()
  • wp-includes/link-template.php: admin_url()
  • wp-includes/link-template.php: includes_url()
  • wp-includes/plugin.php: do_action()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: get_option()
  • wp-includes/media.php: wp_max_upload_size()
  • wp-includes/ms-functions.php: is_upload_space_available()
  • wp-includes/load.php: is_wp_error()
  • Show 25 more uses Hide more uses

Used By

  • wp-admin/includes/media.php: media_upload_type_form()

User Contributed Notes

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

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

发布评论

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