wp_iframe( callable $content_func, mixed $args )
- Since
- 2.5.0, 5.3.0
- Source
wp-admin/includes/media.php:553
Compatibility
- WordPress
- since 5.3.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.
Parameters
$content_funccallable- Function that outputs the content.
$argsmixed- Optional additional parameters to pass to the callback function when it's called.
Performance profile
How much work a call to wp_iframe() 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
- Moderate
- Scaling
- Constant
- Instructions
- 89–107
- Plugin surface
- 9 hooks
- Called by
- 3
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 107.
Third-party callbacks on 'admin_enqueue_scripts', 'admin_print_styles-media-upload-popup', 'admin_print_styles' run inside this call, and their cost is not bounded by anything here.
3 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
do_action()called directly - optionoption read or write
get_option()one call below wp_iframe()
Further down the call graph this can also reach cache, serialize, query 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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_iframe() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_string($content_func) | 89–100 | _wp_admin_html_begin(), bloginfo(), _e(), _e(), wp_enqueue_style(), admin_url(), esc_js(), is_rtl(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), get_user_option(), sanitize_html_class(), call_user_func_array(), do_action() |
is_string($content_func) | 93–104 | _wp_admin_html_begin(), bloginfo(), _e(), _e(), wp_enqueue_style(), admin_url(), esc_js(), is_rtl(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), get_user_option(), sanitize_html_class(), call_user_func_array(), do_action() |
!is_string($content_func) | 94–103 | _wp_admin_html_begin(), bloginfo(), _e(), _e(), wp_enqueue_style(), wp_enqueue_style(), admin_url(), esc_js(), is_rtl(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), get_user_option(), sanitize_html_class(), call_user_func_array(), do_action() |
is_string($content_func) | 98–107 | _wp_admin_html_begin(), bloginfo(), _e(), _e(), wp_enqueue_style(), wp_enqueue_style(), admin_url(), esc_js(), is_rtl(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), get_user_option(), sanitize_html_class(), call_user_func_array(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 107 | 89–107 | 7 | |
| 8.5 | 107 | 89–107 | 7 | |
| 8.4 | 107 | 89–107 | 7 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 113 | 89–113 | 7 | |
| 8.2 | 113 | 89–113 | 7 | |
| 8.1 | 113 | 89–113 | 7 | 1 more instruction than PHP 7.4 |
| 7.4 | 112 | 88–112 | 7 |
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 · 9
9 hooks fire while wp_iframe() runs, in this order:
- do_action( admin_enqueue_scripts )actionline 578 (+25 into the body)
Fires when enqueuing scripts for all admin pages.
- do_action( admin_print_styles-media-upload-popup )actionline 585 (+32 into the body)
Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are printed.
- do_action( admin_print_styles )actionline 588 (+35 into the body)
Fires when styles are printed for all admin pages.
- do_action( admin_print_scripts-media-upload-popup )actionline 595 (+42 into the body)
Fires when admin scripts enqueued for the legacy (pre-3.5.0) media upload popup are printed.
- do_action( admin_print_scripts )actionline 598 (+45 into the body)
Fires when scripts are printed for all admin pages.
- do_action( admin_head-media-upload-popup )actionline 606 (+53 into the body)
Fires when scripts enqueued for the admin header for the legacy (pre-3.5.0) media upload popup are printed.
- do_action( admin_head_{$content_func} )actionline 621 (+68 into the body)
Fires in the admin header for each specific form tab in the legacy (pre-3.5.0) media upload popup.
- do_action( admin_print_footer_scripts )actionline 641 (+88 into the body)
Prints any scripts and data queued for the footer.
Uses · 11
- _wp_admin_html_begin()Prints out the beginning of the admin HTML header.
- bloginfo()Displays information about the current site.
- _e()Displays translated text.
- wp_enqueue_style()Enqueues a CSS stylesheet.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- esc_js()Escapes single quotes, `"`, ``, `&`, and fixes line endings.
- admin_url()Retrieves the URL to the admin area for the current site.
- is_rtl()Determines whether the current locale is right-to-left (RTL).
- do_action()Calls the callback functions that have been added to an action hook.
- sanitize_html_class()Sanitizes an HTML classname to ensure it only contains valid characters.
- get_user_option()Retrieves user option that can be either per Site or per Network.
Used by · 3
- media_upload_gallery()Retrieves the legacy media uploader form in an iframe.
- media_upload_library()Retrieves the legacy media library form in an iframe.
- wp_media_upload_handler()Handles the process of uploading media.
Source code
function wp_iframe( $content_func, ...$args ) { global $body_id; _wp_admin_html_begin(); ?> <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title> <?php wp_enqueue_style( 'colors' ); // Check callback name for 'media'. if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && str_starts_with( (string) $content_func[1], 'media' ) ) || ( ! is_array( $content_func ) && str_starts_with( $content_func, 'media' ) ) ) { wp_enqueue_style( 'deprecated-media' ); } ?> <script> addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup', isRtl = <?php echo (int) is_rtl(); ?>; </script> <?php /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_enqueue_scripts', 'media-upload-popup' ); /** * Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_print_styles-media-upload-popup' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_print_styles' ); /** * Fires when admin scripts enqueued for the legacy (pre-3.5.0) media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_print_scripts-media-upload-popup' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_print_scripts' ); /** * Fires when scripts enqueued for the admin header for the legacy (pre-3.5.0) * media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_head-media-upload-popup' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_head' ); if ( is_string( $content_func ) ) { /** * Fires in the admin header for each specific form tab in the legacy * (pre-3.5.0) media upload popup. * * The dynamic portion of the hook name, `$content_func`, refers to the form * callback for the media upload type. * * @since 2.5.0 */ do_action( "admin_head_{$content_func}" ); } $body_id_attr = ''; if ( isset( $body_id ) ) { $body_id_attr = ' id="' . $body_id . '"'; } ?> </head> <body<?php echo $body_id_attr; ?> class="wp-core-ui no-js <?php echo 'admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'modern' ); ?>">Changelog
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
...$args parameter by adding it to the function signature.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.