Title: wp_iframe
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_iframe( callable $content_func, mixed $args )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#user-contributed-notes)

Outputs the iframe to display the media upload page.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#parameters)󠁿

 `$content_func`callablerequired

Function that outputs the content.

`$args`mixedoptional

Optional additional parameters to pass to the callback function when it’s called.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#source)󠁿

    ```php
    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' ); ?>">
    	<script>
    	document.body.className = document.body.className.replace('no-js', 'js');
    	</script>
    	<?php

    	call_user_func_array( $content_func, $args );

    	/** This action is documented in wp-admin/admin-footer.php */
    	do_action( 'admin_print_footer_scripts' );

    	?>
    	<script>if(typeof wpOnload==='function')wpOnload();</script>
    	</body>
    	</html>
    	<?php
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/media.php#L553)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/media.php#L553-L648)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#hooks)󠁿

 [do_action( ‘admin_enqueue_scripts’, string $hook_suffix )](https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/)

Fires when enqueuing scripts for all admin pages.

 [do_action( ‘admin_head’ )](https://developer.wordpress.org/reference/hooks/admin_head/)

Fires in head section for all admin pages.

 [do_action( ‘admin_head-media-upload-popup’ )](https://developer.wordpress.org/reference/hooks/admin_head-media-upload-popup/)

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}” )](https://developer.wordpress.org/reference/hooks/admin_head_content_func/)

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’ )](https://developer.wordpress.org/reference/hooks/admin_print_footer_scripts/)

Prints any scripts and data queued for the footer.

 [do_action( ‘admin_print_scripts’ )](https://developer.wordpress.org/reference/hooks/admin_print_scripts/)

Fires when scripts are printed for all admin pages.

 [do_action( ‘admin_print_scripts-media-upload-popup’ )](https://developer.wordpress.org/reference/hooks/admin_print_scripts-media-upload-popup/)

Fires when admin scripts enqueued for the legacy (pre-3.5.0) media upload popup 
are printed.

 [do_action( ‘admin_print_styles’ )](https://developer.wordpress.org/reference/hooks/admin_print_styles/)

Fires when styles are printed for all admin pages.

 [do_action( ‘admin_print_styles-media-upload-popup’ )](https://developer.wordpress.org/reference/hooks/admin_print_styles-media-upload-popup/)

Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are
printed.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#related)󠁿

| Uses | Description | 
| [_wp_admin_html_begin()](https://developer.wordpress.org/reference/functions/_wp_admin_html_begin/)`wp-admin/includes/template.php` |

Prints out the beginning of the admin HTML header.

  | 
| [esc_js()](https://developer.wordpress.org/reference/functions/esc_js/)`wp-includes/formatting.php` |

Escapes single quotes, `"`, , `&amp;`, and fixes line endings.

  | 
| [sanitize_html_class()](https://developer.wordpress.org/reference/functions/sanitize_html_class/)`wp-includes/formatting.php` |

Sanitizes an HTML classname to ensure it only contains valid characters.

  | 
| [bloginfo()](https://developer.wordpress.org/reference/functions/bloginfo/)`wp-includes/general-template.php` |

Displays information about the current site.

  | 
| [is_rtl()](https://developer.wordpress.org/reference/functions/is_rtl/)`wp-includes/l10n.php` |

Determines whether the current locale is right-to-left (RTL).

  | 
| [get_user_option()](https://developer.wordpress.org/reference/functions/get_user_option/)`wp-includes/user.php` |

Retrieves user option that can be either per Site or per Network.

  | 
| [_e()](https://developer.wordpress.org/reference/functions/_e/)`wp-includes/l10n.php` |

Displays translated text.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  | 
| [wp_enqueue_style()](https://developer.wordpress.org/reference/functions/wp_enqueue_style/)`wp-includes/functions.wp-styles.php` |

Enqueues a CSS stylesheet.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#)

| Used by | Description | 
| [wp_media_upload_handler()](https://developer.wordpress.org/reference/functions/wp_media_upload_handler/)`wp-admin/includes/media.php` |

Handles the process of uploading media.

  | 
| [media_upload_gallery()](https://developer.wordpress.org/reference/functions/media_upload_gallery/)`wp-admin/includes/media.php` |

Retrieves the legacy media uploader form in an iframe.

  | 
| [media_upload_library()](https://developer.wordpress.org/reference/functions/media_upload_library/)`wp-admin/includes/media.php` |

Retrieves the legacy media library form in an iframe.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Formalized the existing and already documented `...$args` parameter by adding it to the function signature. | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_iframe/?output_format=md#comment-content-1505)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_iframe/#comment-1505)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_iframe%2F%23comment-1505)
    Vote results for this note: -2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_iframe%2F%23comment-1505)
 4. **Demonstrate how to add new tab in the media upload iframe**
 5.     ```php
        // Add the tab.
        add_filter( 'media_upload_tabs', 'wpdocs_my_upload_tab' );
        function wpdocs_my_upload_tab( $tabs ) {
        	$tabs['mytabname'] = __( 'My Tab Name', 'textdomain' );
        	return $tabs;
        }
    
        // Call the new tab with wp_iframe.
        add_action( 'media_upload_mytabname', 'wpdocs_add_my_new_form' );
        function wpdocs_add_my_new_form() {
        	wp_iframe( 'wpdocs_my_new_form' );
        }
    
        // The tab content.
        function wpdocs_my_new_form() {
        	echo '<p>' . __( 'Example HTML content goes here.', 'textdomain' ) . '</p>';
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_iframe%2F%3Freplytocom%3D1505%23feedback-editor-1505)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_iframe%2F)
before being able to contribute a note or feedback.