wppaste
WordPress

media_upload_form( array $errors = null )

Since
2.5.0
Source
wp-admin/includes/media.php:2111
Outputs the legacy media upload form.

Parameters

$errorsarrayoptional
Default: null

Hooks fired · 10

10 hooks fire while media_upload_form() runs, in this order:

  1. do_action( upload_ui_over_quota )actionline 2160 (+49 into the body)

    Fires when an upload will exceed the defined upload space quota for a network site.

  2. do_action( pre-upload-ui )actionline 2169 (+58 into the body)

    Fires just before the legacy (pre-3.5.0) upload interface is loaded.

  3. apply_filters( upload_post_params )filterline 2187 (+76 into the body)

    Filters the media upload post parameters.

  4. apply_filters( wp_prevent_unsupported_mime_type_uploads )filterline 2217 (+106 into the body)

    Filter whether the server should prevent uploads for image types it doesn't support. Default true.

  5. apply_filters( plupload_init )filterline 2238 (+127 into the body)

    Filters the default Plupload settings.

  6. do_action( pre-plupload-upload-ui )actionline 2269 (+158 into the body)

    Fires before the upload interface loads.

  7. do_action( post-plupload-upload-ui )actionline 2286 (+175 into the body)

    Fires after the upload interface loads.

  8. do_action( pre-html-upload-ui )actionline 2297 (+186 into the body)

    Fires before the upload button in the media upload interface.

  9. do_action( post-html-upload-ui )actionline 2318 (+207 into the body)

    Fires after the upload button in the media upload interface.

  10. do_action( post-upload-ui )actionline 2338 (+227 into the body)

    Fires on the post upload UI screen.

Uses · 23

  • _device_can_upload()Tests if the current device has the capability to upload files.
  • __()Retrieves the translation of $text.
  • admin_url()Retrieves the URL to the admin area for the current site.
  • wp_max_upload_size()Determines the maximum upload size allowed in php.ini.
  • is_wp_error()Checks whether the given variable is a WordPress Error.
  • is_multisite()Determines whether Multisite is enabled.
  • is_upload_space_available()Determines if there is any upload space left in the current blog's quota.
  • do_action()Calls the callback functions that have been added to an action hook.
  • wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • wp_is_mobile()Test if the current browser runs on a mobile device (smart phone, tablet, etc.).
  • str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
Show all 23
  • wp_image_editor_supports()Tests whether there is an editor that supports a given mime type or methods.
  • absint()Converts a value to non-negative integer.
  • get_option()Retrieves an option value based on an option name.
  • wp_json_encode()Encodes a variable into JSON, with some confidence checks.
  • _e()Displays translated text.
  • _ex()Displays translated string with gettext context.
  • esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
  • submit_button()Echoes a submit button, with provided text and appropriate class(es).
  • _x()Retrieves translated string with gettext context.
  • esc_html()Escaping for HTML blocks.
  • size_format()Converts a number of bytes to the largest unit the bytes will fit into.

Used by · 1

Source

function media_upload_form( $errors = null ) {	global $type, $tab; 	if ( ! _device_can_upload() ) {		echo '<p>' . sprintf(			/* translators: %s: https://apps.wordpress.org/ */			__( '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'] ) ? (int) $_REQUEST['post_id'] : 0;	$_type             = $type ?? '';	$_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' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 	$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 ); 	/*	* Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,

History

Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.