Make WordPress Core

Changeset 63626


Ignore:
Timestamp:
09/15/2026 05:50:29 PM (8 weeks ago)
Author:
westonruter
Message:

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.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/admin-header.php

    r63481 r63626  
    274274 *
    275275 * @since 2.3.0
     276 * @since 7.2.0 Also applied in the Customizer context, where the body tag does not
     277 *              have the wp-admin class.
    276278 *
    277279 * @param string $classes Space-separated list of CSS classes.
  • trunk/src/wp-admin/customize.php

    r63352 r63626  
    186186 */
    187187do_action( 'customize_controls_head' );
     188
     189/** This filter is documented in wp-admin/admin-header.php */
     190$additional_body_class = apply_filters( 'admin_body_class', '' );
     191if ( is_string( $additional_body_class ) && '' !== $additional_body_class ) {
     192        $body_class .= ' ' . $additional_body_class;
     193}
    188194?>
    189195</head>
Note: See TracChangeset for help on using the changeset viewer.