^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助,如果有代码出错,请联系站长解决
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数media_upload_form()用法示例

media_upload_form( array $errors = null )

Outputs the legacy media upload form.


描述


参数

$errors

(array)
(Optional)

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

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

更新日志

Version 描述
2.5.0 Introduced.

相关函数

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


Used By

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

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈