• Resolved Tony Hayes

    (@majick)


    I have wanted to use this on a live site to help find and fix a bug, but the problem is/was it doesn’t have any role filtering so it would be publicly viewable…

    So I added this hack to not run the Blackbox display output unless you are of an administrator role. Although of course it could be something that could be incorporated into the class loading in a future version (with a role filter available too, or perhaps just via the manage_options capability.)

    add_action('plugins_loaded','blackbox_user_filter');
    function blackbox_user_filter() {
    	if (!class_exists('BlackBox_Hook')) {return;}
    	global $current_user; $current_user = wp_get_current_user();
    	if (in_array('administrator', $current_user->roles)) {return;}
    	remove_action('admin_footer', array('BlackBox_Hook', 'footer'));
    	remove_action('wp_footer', array('BlackBox_Hook', 'footer'));
    }

    I noticed the forked Github version had an is_admin() check to attempt solve this, but is_admin is not what needs to be used in this case, for it totally limits the use of the Blackbox to just the admin area, crippling the plugin use. (I have done a fork and pull request on github with the same code above.)

    Also, I did a style hack to moves the Debug Bar to the bottom of the screen so it doesn’t conflict with the existing WP admin bar. (Since there is a screen toggle button already, there could be another button that adds or removes these styles and thus moves it from top to bottom.) Still, defaulting to the bottom would be better because of the admin bar.

    #blackbox-web-debug {bottom:0px !important; top:initial !important;}
    #blackbox-web-debug .debug-panel {position: absolute; top: -410px; width:99%;}
    #blackbox-profiler {top:-70px !important;}

    Thanks for an awesome plugin, very handy it tracking down some particularly ghostly bugs. hmmmmmm just had an idea, a template loop trace display panel could be a good addition… ??

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘fixed the admin only display problem’ is closed to new replies.