From ef67c9badaabbd203608f0a0a098cc34fc9c2bf3 Mon Sep 17 00:00:00 2001 From: majick777 Date: Wed, 12 Aug 2015 18:41:10 +1000 Subject: [PATCH] admin use only fix Blackbox needs to be able to debug on the front-end, but only show for developers (ie. administrator role.) Using is_admin() (a change from the original Blackbox) prevented this version from any front-end use at all. This is a hacky fix after the fact, but it works. It could be better implemented in the Blackbox class. And possibly provide a filter for allowed roles and/or capabilities so the plugin only loads when it is needed. --- index.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 3de58a4..0643130 100644 --- a/index.php +++ b/index.php @@ -21,5 +21,13 @@ require_once BLACKBOX_DIR.'/application/BlackBox/WPConstants.php'; require_once BLACKBOX_DIR.'/application/BlackBox/WPGlobals.php'; -if ( is_admin() ) - BlackBox::init(); +BlackBox::init(); + +// remove the blackbox display if not administrator role +add_action('plugins_loaded','blackbox_user_filter'); +function blackbox_user_filter() { + 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')); +}