WordPress Admin Body Classes

PHP
<?php

function add_custom_admin_body_classes($classes)
{
    // Nutzer-ID hinzufügen
    $current_user_id = get_current_user_id();
    if ($current_user_id) {
        $classes .= ' user-id-' . $current_user_id;
    }

    // Nutzerrolle hinzufügen
    if (is_admin() && is_user_logged_in()) {
        $user = wp_get_current_user();
        if (! empty($user->roles)) {
            $classes .= ' user-role-' . sanitize_html_class($user->roles[0]);
        }
    }

    // Custom Post Type hinzufügen
    if (is_admin() && function_exists('get_current_screen')) {
        $screen = get_current_screen();
        if ($screen && $screen->post_type) {
            $classes .= ' post-type-' . sanitize_html_class($screen->post_type);
        }
    }

    return $classes;
}
add_filter('admin_body_class', 'add_custom_admin_body_classes');