wpseek.com
A WordPress-centric search engine for devs and theme authors
iframe_header › WordPress Function
Since2.7.0
Deprecatedn/a
› iframe_header ( $title = '', $deprecated = false )
| Parameters: (2) |
|
| Defined at: |
|
| Codex: |
Generic Iframe header for use with Thickbox.
Source
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' ); ?> › <?php echo $title; ?> — <?php _e( 'WordPress' ); ?></title>
<?php
wp_enqueue_style( 'colors' );
// Print the global admin inline scripts through the script tag API so the
// `wp_inline_script_attributes` filter (e.g. a CSP nonce) applies.
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();
};
}
}
function tb_close() {
( window.dialogArguments || opener || parent || top ).tb_remove();
}
JS
);
wp_print_inline_script_tag(
sprintf(
'Object.assign( window, %s );',
wp_json_encode(
array(
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
'pagenow' => $current_screen->id ?? '',
'typenow' => $current_screen->post_type ?? '',
'adminpage' => $admin_body_class,
'thousandsSeparator' => $wp_locale->number_format['thousands_sep'],
'decimalPoint' => $wp_locale->number_format['decimal_point'],
'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', $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 ); ?>">
<?php
wp_print_inline_script_tag(
<<<'JS'
document.body.className = document.body.className.replace( 'no-js', 'js' );
JS
);
}