Skip to content

Commit

Permalink
Docs: Consistently document the $body_id global as a string.
Browse files Browse the repository at this point in the history
Includes declaring the global at the beginning of `wp_iframe()` and `iframe_header()`.

Follow-up to [32642], [32643].

Props mukesh27, upadalavipul.
Fixes #60032.

git-svn-id: https://develop.svn.wordpress.org/trunk@57181 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Dec 11, 2023
1 parent 8df5178 commit 8e8adbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,14 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
* by adding it to the function signature.
*
* @global int $body_id
* @global string $body_id
*
* @param callable $content_func Function that outputs the content.
* @param mixed ...$args Optional additional parameters to pass to the callback function when it's called.
*/
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>
Expand Down Expand Up @@ -603,8 +605,8 @@ function wp_iframe( $content_func, ...$args ) {

$body_id_attr = '';

if ( isset( $GLOBALS['body_id'] ) ) {
$body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
if ( isset( $body_id ) ) {
$body_id_attr = ' id="' . $body_id . '"';
}

?>
Expand Down
10 changes: 5 additions & 5 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2118,14 +2118,17 @@ function _admin_search_query() {
*
* @global string $hook_suffix
* @global string $admin_body_class
* @global string $body_id
* @global WP_Locale $wp_locale WordPress date and time locale object.
*
* @param string $title Optional. Title of the Iframe page. Default empty.
* @param bool $deprecated Not used.
*/
function iframe_header( $title = '', $deprecated = false ) {
global $hook_suffix, $admin_body_class, $body_id, $wp_locale;

show_admin_bar( false );
global $hook_suffix, $admin_body_class, $wp_locale;

$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );

$current_screen = get_current_screen();
Expand Down Expand Up @@ -2179,10 +2182,7 @@ function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_r
?>
</head>
<?php
/**
* @global string $body_id
*/
$admin_body_id = isset( $GLOBALS['body_id'] ) ? 'id="' . $GLOBALS['body_id'] . '" ' : '';
$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', '' );
Expand Down

0 comments on commit 8e8adbb

Please sign in to comment.