How to fix the admin menu margin-top bug in WordPress 5.5?

I ran into that issue too, and it turns out that it was because there actually was an error that wasn’t displaying. Once I fixed that underlying error, the top margin problem went away.

This is in wp-admin/admin-header.php:

// Print a CSS class to make PHP errors visible.
if ( error_get_last() && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ) {
    $admin_body_class .= ' php-error';
}

So I temporarily added a display of that error_get_last() output to one of my plugins:

$debug = print_r(error_get_last(),true);
echo '<p>php-error: '.esc_attr($debug).'</p>';

That showed me where the underlying error was. I fixed it, and problem solved!

Leave a Comment