Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions debug-quick-look.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ class DebugQuickLook {
*/
public function init() {
if ( ! $this->has_debug_constant() ) {
add_action( 'wp_head', array( $this, 'add_warning_css' ) );
add_action( 'admin_head', array( $this, 'add_warning_css' ) );
add_action( 'wp_head' , array( $this, 'add_warning_css' ) );
add_action( 'admin_head', array( $this, 'add_warning_css' ) );
}
add_action( 'admin_init', array( $this, 'process_debug_type' ) );
add_action( 'admin_bar_menu', array( $this, 'admin_bar_links' ), 9999 );
add_action( 'admin_init' , array( $this, 'process_debug_type' ) );
add_action( 'admin_bar_menu', array( $this, 'admin_bar_links' ), 9999 );
}

public function user_can_view_log() {
return current_user_can( apply_filters( 'debug_quick_look_capability', 'manage_options' ) );
}

/**
Expand All @@ -67,7 +71,7 @@ public function init() {
public function add_warning_css() {

// Bail if current user doesnt have cap or the constant is set.
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! $this->user_can_view_log() ) {
return;
}

Expand All @@ -91,7 +95,7 @@ public function add_warning_css() {
* @return boolean
*/
public function has_debug_constant() {
return defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ? true : false;
return apply_filters( 'debug_quick_look_has_constant', defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG );
}

/**
Expand Down Expand Up @@ -126,7 +130,7 @@ public function check_file_data() {
public function process_debug_type() {

// Bail if current user doesnt have cap.
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! $this->user_can_view_log() ) {
return;
}

Expand Down Expand Up @@ -322,7 +326,7 @@ public function parse_log( $file = '', $count = 100, $size = 512 ) {
public function admin_bar_links( WP_Admin_Bar $wp_admin_bar ) {

// Bail if current user doesnt have cap.
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! $this->user_can_view_log() ) {
return;
}

Expand Down