wp_plupload_default_settings()
- Since
- 3.4.0
- Source
wp-includes/media.php:4312
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
- Scaling
- Scales with input
- Instructions
- 12–119
- Plugin surface
- 2 hooks
- Called by
- 1
Reads stored settings via get_site_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 130.
Third-party callbacks on 'plupload_default_settings', 'plupload_default_params' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionnetwork option
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
$data | 12 | wp_scripts(), ->get_data() |
!is_multisite() | 93–116 | wp_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–119 | wp_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 130 | 12–119 | 12 | |
| 8.5 | 130 | 12–119 | 12 | |
| 8.4 | 130 | 12–119 | 12 | 12 fewer instructions than PHP 8.3 |
| 8.3 | 142 | 15–131 | 12 | |
| 8.2 | 142 | 15–131 | 12 | |
| 8.1 | 142 | 15–131 | 12 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 144 | 15–133 | 12 |
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:
- apply_filters( plupload_default_settings )filterline 4374 (+62 into the body)
Filters the Plupload default settings.
- apply_filters( plupload_default_params )filterline 4387 (+75 into the body)
Filters the Plupload default parameters.
Uses · 13
- wp_scripts()Initializes $wp_scripts if it has not been set.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- wp_max_upload_size()Determines the maximum upload size allowed in php.ini.
- get_allowed_mime_types()Retrieves the list of allowed mime types and file extensions.
- admin_url()Retrieves the URL to the admin area for the current site.
- wp_is_mobile()Test if the current browser runs on a mobile device (smart phone, tablet, etc.).
- wp_image_editor_supports()Tests whether there is an editor that supports a given mime type or methods.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- _device_can_upload()Tests if the current device has the capability to upload files.
- 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.
Show all 13
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
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.
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.