- This topic is empty.
-
AuthorPosts
-
December 14, 2011 at 11:44 am #35645
gilgimech
ParticipantIf 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.
Put this code in your functions.php file.
if ((error_reporting() && is_admin())) {
echo '';
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?
December 14, 2011 at 6:16 pm #92763TheDoc
MemberThat’s interesting. I would assume if there was an error the toolbar shouldn’t even load.
December 14, 2011 at 6:44 pm #92764gilgimech
ParticipantYeah, 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.
January 11, 2012 at 9:22 pm #94441gilgimech
ParticipantIf anyone else had any issue with this too. I’ve come up with a couple of solutions.
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();?>Error: []
on line
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 );
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.