wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_iframe › WordPress Function
Since2.5.0
Deprecatedn/a
› wp_iframe ( $content_func, $args )
| Parameters: (2) |
|
| Defined at: |
|
| Codex: | |
| Change Log: |
|
Outputs the iframe to display the media upload page.
Source
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' );
}
wp_print_inline_script_tag(
<<<'JS'
function addLoadEvent( func ) {
if ( typeof jQuery !== 'undefined' ) {
jQuery( function () {
func();
} );
} else if ( typeof wpOnload !== 'function' ) {
window.wpOnload = func;
} else {
const oldOnload = window.wpOnload;
window.wpOnload = function () {
oldOnload();
func();
};
}
}
JS
);
wp_print_inline_script_tag(
sprintf(
'Object.assign( window, %s );',
wp_json_encode(
array(
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
'pagenow' => 'media-upload-popup',
'adminpage' => 'media-upload-popup',
'isRtl' => (int) is_rtl(),
),
JSON_HEX_TAG | JSON_UNESCAPED_SLASHES
)
)
);
/** 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' ); ?>">
<?php
wp_print_inline_script_tag(
<<<'JS'
document.body.className = document.body.className.replace( 'no-js', 'js' );
JS
);
call_user_func_array( $content_func, $args );
/** This action is documented in wp-admin/admin-footer.php */
do_action( 'admin_print_footer_scripts' );
wp_print_inline_script_tag(
<<<'JS'
if ( typeof wpOnload === 'function' ) {
wpOnload();
}
JS
);
?>
</body>
</html>
<?php
}