apply_filters( ‘admin_body_class’, string $classes )

Filters the CSS classes for the body tag in the admin.

Description

This filter differs from the ‘post_class’ and ‘body_class’ filters in two important ways:

  1. $classes is a space-separated string of class names instead of an array.
  2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui, and no-js cannot be removed.

Parameters

$classesstring
Space-separated list of CSS classes.

Source

$admin_body_classes = apply_filters( 'admin_body_class', '' );

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    When adding new classes to the body, you should make sure to add spaces before and after your class name. This prevents accidental concatenation of two plugins class-names.

    Example:

    function admin_body_class( $classes ) {
        // Wrong: No space in the beginning/end.
        $classes .= 'my-class1 my-class2';
    
        // Right: Add a leading space and a trailing space.
        $classes .= ' my-class1 my-class2 ';
    
        return $classes;
    }

You must log in before being able to contribute a note or feedback.