wppaste
WordPress

iframe_header( string $title = '', bool $deprecated = false )

Since
2.7.0
Source
wp-admin/includes/template.php:2130
Generic Iframe header for use with Thickbox.

Compatibility

WordPress
since 2.7.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

$titlestringoptional
Title of the Iframe page. Default empty.Default: ''
$deprecatedbooloptional
Not used.Default: false

Performance profile

How much work a call to iframe_header() 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

Reaches the database via get_user_by().

Scaling
Constant

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

Instructions
167–170

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

Plugin surface
8 hooks

Third-party callbacks on 'admin_enqueue_scripts', 'admin_print_styles-{$hook_suffix}', 'admin_print_styles' run inside this call, and their cost is not bounded by anything here.

Called by
2

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

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksdo_action()called directly
  • cacheobject cachewp_cache_get()one call below iframe_header()
  • serializeserialisationmaybe_unserialize()one call below iframe_header()
  • querycontent queryget_user_by()one call below iframe_header()

Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 1 distinct outcome

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

WhenInstructionsCalls it makes
always167–170show_admin_bar(), get_current_screen(), get_option(), get_option(), header(), _wp_admin_html_begin(), bloginfo(), _e(), wp_enqueue_style(), admin_url(), esc_js(), esc_js(), esc_js(), esc_js(), esc_js(), esc_js(), is_rtl(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), do_action(), get_user_locale(), strtolower(), sanitize_html_class(), get_user_option(), sanitize_html_class(), is_rtl(), apply_filters(), ltrim(), esc_attr()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev171167–1702
8.5171167–1702
8.4171167–17026 fewer instructions than PHP 8.3
8.3177173–1762
8.2177173–1762
8.1177173–17621 fewer instruction than PHP 7.4
7.4178173–1772

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

8 hooks fire while iframe_header() runs, in this order:

  1. do_action( admin_enqueue_scripts )actionline 2159 (+29 into the body)

    Fires when enqueuing scripts for all admin pages.

  2. do_action( admin_print_styles-{$hook_suffix} )actionline 2162 (+32 into the body)

    Fires when styles are printed for a specific admin page based on $hook_suffix.

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

    Fires when styles are printed for all admin pages.

  4. do_action( admin_print_scripts-{$hook_suffix} )actionline 2168 (+38 into the body)

    Fires when scripts are printed for a specific admin page based on $hook_suffix.

  5. do_action( admin_print_scripts )actionline 2171 (+41 into the body)

    Fires when scripts are printed for all admin pages.

  6. do_action( admin_head-{$hook_suffix} )actionline 2174 (+44 into the body)

    Fires in head section for a specific admin page.

  7. do_action( admin_head )actionline 2177 (+47 into the body)

    Fires in head section for all admin pages.

  8. apply_filters( admin_body_class )filterline 2192 (+62 into the body)

    Filters the CSS classes for the body tag in the admin.

Uses · 16

Show all 16

Used by · 2

Source code

function iframe_header( $title = '', $deprecated = false ) {	global $hook_suffix, $admin_body_class, $body_id, $wp_locale; 	show_admin_bar( false ); 	$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix ); 	$current_screen = get_current_screen(); 	header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );	_wp_admin_html_begin();	?><title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>	<?php	wp_enqueue_style( 'colors' );	?><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();}}};function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',	pagenow = '<?php echo esc_js( $current_screen->id ); ?>',	typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',	adminpage = '<?php echo esc_js( $admin_body_class ); ?>',	thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',	decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',	isRtl = <?php echo (int) is_rtl(); ?>;</script>	<?php	/** This action is documented in wp-admin/admin-header.php */	do_action( 'admin_enqueue_scripts', $hook_suffix ); 	/** This action is documented in wp-admin/admin-header.php */	do_action( "admin_print_styles-{$hook_suffix}" );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 	/** This action is documented in wp-admin/admin-header.php */	do_action( 'admin_print_styles' ); 	/** This action is documented in wp-admin/admin-header.php */	do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 	/** This action is documented in wp-admin/admin-header.php */	do_action( 'admin_print_scripts' ); 	/** This action is documented in wp-admin/admin-header.php */	do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 	/** This action is documented in wp-admin/admin-header.php */	do_action( 'admin_head' ); 	$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );	$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'modern' ); 	if ( is_rtl() ) {		$admin_body_class .= ' rtl';	} 	?></head>	<?php	$admin_body_id = isset( $body_id ) ? 'id="' . $body_id . '" ' : ''; 	/** This filter is documented in wp-admin/admin-header.php */	$admin_body_classes = apply_filters( 'admin_body_class', '' );	$admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );	?><body <?php echo $admin_body_id; ?>class="wp-admin wp-core-ui no-js iframe <?php echo esc_attr( $admin_body_classes ); ?>"><script>(function(){var c = document.body.className;c = c.replace(/no-js/, 'js');document.body.className = c;})();</script>	<?php}

Changelog

Introduced in 2.7.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/template.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.