wppaste
WordPress

wp_iframe( callable $content_func, mixed $args )

Since
2.5.0, 5.3.0
Source
wp-admin/includes/media.php:553
Outputs the iframe to display the media upload page.

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

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

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
89–107

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

Plugin surface
9 hooks

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.

Called by
3

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

What it touches

  • hookthird-party callbacksdo_action()called directly
  • optionoption read or writeget_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.

WhenInstructionsCalls 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

PHPCompiledExecutedBranchesNotes
8.6-dev10789–1077
8.510789–1077
8.410789–10776 fewer instructions than PHP 8.3
8.311389–1137
8.211389–1137
8.111389–11371 more instruction than PHP 7.4
7.411288–1127

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:

  1. do_action( admin_enqueue_scripts )actionline 578 (+25 into the body)

    Fires when enqueuing scripts for all admin pages.

  2. 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.

  3. do_action( admin_print_styles )actionline 588 (+35 into the body)

    Fires when styles are printed for all admin pages.

  4. 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.

  5. do_action( admin_print_scripts )actionline 598 (+45 into the body)

    Fires when scripts are printed for all admin pages.

  6. 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.

  7. do_action( admin_head )actionline 609 (+56 into the body)

    Fires in head section for all admin pages.

  8. 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.

  9. do_action( admin_print_footer_scripts )actionline 641 (+88 into the body)

    Prints any scripts and data queued for the footer.

Uses · 11

Used by · 3

Source code

function wp_iframe( $content_func, ...$args ) {	global $body_id; 	_wp_admin_html_begin();	?>	<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php _e( 'Uploads' ); ?> &#8212; <?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.

  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.

5.3.0
Formalized the existing and already documented ...$args parameter by adding it to the function signature.from the docblock
2.5.0
Introduced.from the docblock

About 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.