wppaste
WordPress

wp_plupload_default_settings()

Since
3.4.0
Source
wp-includes/media.php:4312
Prints default Plupload arguments.

Compatibility

WordPress
since 3.4.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to wp_plupload_default_settings() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reads stored settings via get_site_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
12–119

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 130.

Plugin surface
2 hooks

Third-party callbacks on 'plupload_default_settings', 'plupload_default_params' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionnetwork optionget_site_option()one call below wp_plupload_default_settings()

Further down the call graph this can also reach cache, query, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 3 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_plupload_default_settings() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$data12wp_scripts(), ->get_data()
!is_multisite()93–116wp_scripts(), ->get_data(), wp_max_upload_size(), get_allowed_mime_types(), array_keys(), admin_url(), wp_is_mobile(), wp_image_editor_supports(), wp_image_editor_supports(), wp_image_editor_supports(), apply_filters(), apply_filters(), wp_create_nonce(), wp_is_mobile(), _device_can_upload(), is_multisite(), wp_json_encode(), ->add_data()
is_multisite()96–119wp_scripts(), ->get_data(), wp_max_upload_size(), get_allowed_mime_types(), array_keys(), admin_url(), wp_is_mobile(), wp_image_editor_supports(), wp_image_editor_supports(), wp_image_editor_supports(), apply_filters(), apply_filters(), wp_create_nonce(), wp_is_mobile(), _device_can_upload(), is_multisite(), is_upload_space_available(), wp_json_encode(), ->add_data()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev13012–11912
8.513012–11912
8.413012–1191212 fewer instructions than PHP 8.3
8.314215–13112
8.214215–13112
8.114215–131122 fewer instructions than PHP 7.4
7.414415–13312

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 2

2 hooks fire while wp_plupload_default_settings() runs, in this order:

  1. apply_filters( plupload_default_settings )filterline 4374 (+62 into the body)

    Filters the Plupload default settings.

  2. apply_filters( plupload_default_params )filterline 4387 (+75 into the body)

    Filters the Plupload default parameters.

Uses · 13

Show all 13

Used by · 1

  • wp_enqueue_media()Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.

Source code

function wp_plupload_default_settings() {	$wp_scripts = wp_scripts(); 	$data = $wp_scripts->get_data( 'wp-plupload', 'data' );	if ( $data && str_contains( $data, '_wpPluploadSettings' ) ) {		return;	} 	$max_upload_size    = wp_max_upload_size();	$allowed_extensions = array_keys( get_allowed_mime_types() );	$extensions         = array();	foreach ( $allowed_extensions as $extension ) {		$extensions = array_merge( $extensions, explode( '|', $extension ) );	} 	/*	 * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,	 * and the `flash_swf_url` and `silverlight_xap_url` are not used.	 */	$defaults = array(		'file_data_name' => 'async-upload', // Key passed to $_FILE.		'url'            => admin_url( 'async-upload.php', 'relative' ),		'filters'        => array(			'max_file_size' => $max_upload_size . 'b',			'mime_types'    => array( array( 'extensions' => implode( ',', $extensions ) ) ),		),	); 	/*	 * Currently only iOS Safari supports multiple files uploading,	 * but iOS 7.x has a bug that prevents uploading of videos when enabled.	 * See #29602.	 */	if ( wp_is_mobile()		&& str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' )		&& str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' )	) {		$defaults['multi_selection'] = false;	} 	// Check if WebP images can be edited.	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {		$defaults['webp_upload_error'] = true;	} 	// Check if AVIF images can be edited.	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {		$defaults['avif_upload_error'] = true;	} 	// Check if HEIC images can be edited.	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/heic' ) ) ) {		$defaults['heic_upload_error'] = true;	} 	/**	 * Filters the Plupload default settings.	 *	 * @since 3.4.0	 *	 * @param array $defaults Default Plupload settings array.	 */	$defaults = apply_filters( 'plupload_default_settings', $defaults ); 	$params = array(		'action' => 'upload-attachment',	); 	/**	 * Filters the Plupload default parameters.	 *	 * @since 3.4.0	 *	 * @param array $params Default Plupload parameters array.	 */	$params = apply_filters( 'plupload_default_params', $params ); 	$params['_wpnonce'] = wp_create_nonce( 'media-form' ); 	$defaults['multipart_params'] = $params;

Changelog

Introduced in 3.4.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 6.7.7 tag, from src/wp-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.