Commit f6c43a3b12 for wordpress.org
commit f6c43a3b12b2d30a178a03ee507f42a313648a5f
Author: westonruter <westonruter@git.wordpress.org>
Date: Tue Sep 15 17:51:51 2026 +0000
Customize: Apply the `admin_body_class` filter.
The Customizer was the only admin screen not to expose this filter, leaving plugins without a supported way to add their own classes to the controls frame's `body` element. The filter is applied to an empty string and its result appended to the Customizer's own classes, matching `admin-header.php` and `iframe_header()`, so that `wp-core-ui`, `wp-customizer` and `js` cannot be dropped by a callback that replaces rather than appends. Those classes are relied on throughout `customize-controls.css`.
The filter runs after `customize_controls_head`, mirroring the way `admin-header.php` applies it after `admin_head`, so that callbacks registered from the Customizer's own head hooks still take effect.
Note that the Customizer's `body` element carries `wp-core-ui` but not `wp-admin`, and that `customize.php` does not fire `admin_enqueue_scripts`. A class added here therefore has no effect unless the accompanying styles are enqueued at `customize_controls_enqueue_scripts` or printed at `customize_controls_print_styles`. The filter's docblock records both the new context and the absent `wp-admin` class.
Developed in https://github.com/WordPress/wordpress-develop/pull/12815.
Follow-up to r59480, r61385.
Props afercia, westonruter, mukesh27.
Fixes #65796.
Built from https://develop.svn.wordpress.org/trunk@63626
git-svn-id: http://core.svn.wordpress.org/trunk@62802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index 9b44f528e8..265c91923e 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -273,6 +273,8 @@ unset( $error_get_last );
* and no-js cannot be removed.
*
* @since 2.3.0
+ * @since 7.2.0 Also applied in the Customizer context, where the body tag does not
+ * have the wp-admin class.
*
* @param string $classes Space-separated list of CSS classes.
*/
diff --git a/wp-admin/customize.php b/wp-admin/customize.php
index 75c0865b1f..5acfefb2ac 100644
--- a/wp-admin/customize.php
+++ b/wp-admin/customize.php
@@ -185,6 +185,12 @@ do_action( 'customize_controls_print_scripts' );
* @since 5.5.0
*/
do_action( 'customize_controls_head' );
+
+/** This filter is documented in wp-admin/admin-header.php */
+$additional_body_class = apply_filters( 'admin_body_class', '' );
+if ( is_string( $additional_body_class ) && '' !== $additional_body_class ) {
+ $body_class .= ' ' . $additional_body_class;
+}
?>
</head>
<body class="<?php echo esc_attr( $body_class ); ?>">
diff --git a/wp-includes/version.php b/wp-includes/version.php
index f42a4f30c4..097db933ba 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63625';
+$wp_version = '7.2-alpha-63626';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.