Grow your CSS skills. Land your dream job.

WordPress 3.3 toolbar covers php errors

  • # December 14, 2011 at 11:44 am

    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.

    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

    That’s interesting. I would assume if there was an error the toolbar shouldn’t even load.

    # December 14, 2011 at 6:44 pm

    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.

    # January 11, 2012 at 9:22 pm

    If 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();?>

    < ?php echo $errname; ?> Error: [< ?php echo $errno; ?>]
    < ?php echo $errstr; ?> < ?php echo $errfile; ?> on line
    < ?php echo $errline; ?>

    < ?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 );

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".