If anyone hasn't noticed yet the WordPress 3.3 toolbar (formally the admin head and admin bar) covers the first few lines of php errors. That's pretty annoying. I've got a fix for it though.
What it does is it adds padding to the body if there is an error, so everything except the toolbar get pushed down. Allowing you to see the errors. I haven't done extensive testing of this though, but it seems to be working so far.
Has anyone else come up with a fix for this issue yet?
Yeah, I don't think the WordPress team considered that. I posted something about this issue on the wordpress.org forums and the mod's answer was to use error logs, but then nothing is perfect. Bugs like that are to be expected when there are major changes like the toolbar.
Put this code in your functions.php file.
if ((error_reporting() && is_admin())) {
echo '<style>body{ padding-top: 28px !important; }</style>';
return;
}
What it does is it adds padding to the body if there is an error, so everything except the toolbar get pushed down. Allowing you to see the errors. I haven't done extensive testing of this though, but it seems to be working so far.
Has anyone else come up with a fix for this issue yet?
Here's a plugin that will disable the toolbar.
http://wordpress.org/extend/plugins/old-skool-admin-head/
This code will have the errors output in admin alerts
function customError($errno, $errstr, $errfile, $errline){
$errorType = array (
E_ERROR => 'ERROR',
E_CORE_ERROR => 'CORE ERROR',
E_COMPILE_ERROR => 'COMPILE ERROR',
E_USER_ERROR => 'USER ERROR',
E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR',
E_WARNING => 'WARNING',
E_CORE_WARNING => 'CORE WARNING',
E_COMPILE_WARNING => 'COMPILE WARNING',
E_USER_WARNING => 'USER WARNING',
E_NOTICE => 'NOTICE',
E_USER_NOTICE => 'USER NOTICE',
E_DEPRECATED => 'DEPRECATED',
E_USER_DEPRECATED => 'USER_DEPRECATED',
E_PARSE => 'PARSING ERROR'
);
if (array_key_exists($errno, $errorType)) {
$errname = $errorType[$errno];
} else {
$errname = 'UNKNOWN ERROR';
}
ob_start();?>
<div class="error">
<p>
<strong><?php echo $errname; ?> Error: [<?php echo $errno; ?>]
</strong><?php echo $errstr; ?><strong> <?php echo $errfile; ?></strong> on line
<strong><?php echo $errline; ?></strong>
<p/>
</div>
<?php
echo ob_get_clean();
}
set_error_handler("customError", E_ERROR ^ E_CORE_ERROR ^ E_COMPILE_ERROR ^
E_USER_ERROR ^ E_RECOVERABLE_ERROR ^ E_WARNING ^ E_CORE_WARNING ^
E_COMPILE_WARNING ^ E_USER_WARNING ^ E_NOTICE ^ E_USER_NOTICE ^
E_DEPRECATED ^ E_USER_DEPRECATED ^ E_PARSE );