So why are category classes not added to the admin body class with this function?
I see the current post ID in page source as part of the complete body class, so the basic function of adding body classes to admin with admin_body_class
does work.
Any ideas?
function base_admin_body_class( $classes )
{
// Current action
if ( is_admin() && isset($_GET['action']) ) {
$classes .= 'action-'.$_GET['action'];
}
// Current post ID
if ( is_admin() && isset($_GET['post']) ) {
$classes .= ' ';
$classes .= 'post-'.$_GET['post'];
}
// Get Categories
if ( is_admin() && isset($_GET['post']) ) {
$cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
$cats = wp_list_pluck( $cats, 'slug' );
foreach ( $cats as $cat )
{
$classes .= ' category-' . $cat;
}
}
return $classes;
}
add_filter('admin_body_class', 'base_admin_body_class');