Skip to content

Commit

Permalink
Don't output QM in the theme customizer
Browse files Browse the repository at this point in the history
Rename Query Functions to Query Callers
Add error_reporting level to Environment output
Fix styling of conditionals in admin toolbar
Fix output of nested array/object query vars
  • Loading branch information
johnbillion committed Aug 29, 2012
1 parent a863772 commit 9c9572c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 26 deletions.
6 changes: 3 additions & 3 deletions components/conditionals.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function admin_menu( $menu ) {
$menu[] = $this->menu( array(
'title' => $cond . '()',
'id' => 'query-monitor-' . $cond,
'meta' => array( 'class' => 'qm-true' )
'meta' => array( 'classname' => 'qm-true' )
) );
}

Expand Down Expand Up @@ -55,8 +55,8 @@ function output( $args, $data ) {
function process() {

$conds = apply_filters( 'qm_conditionals', array(
'is_404', 'is_archive', 'is_admin', 'is_attachment', 'is_author', 'is_blog_admin', 'is_category', 'is_comments_popup',
'is_date', 'is_day', 'is_feed', 'is_front_page', 'is_generic_request', 'is_home', 'is_main_site', 'is_month', 'is_network_admin',
'is_404', 'is_archive', 'is_admin', 'is_attachment', 'is_author', 'is_blog_admin', 'is_category', 'is_comments_popup', 'is_date',
'is_day', 'is_feed', 'is_front_page', 'is_generic_request', 'is_home', 'is_main_site', 'is_month', 'is_multitax', 'is_network_admin',
'is_page', 'is_page_template', 'is_paged', 'is_post_type_archive', 'is_preview', 'is_robots', 'is_rtl', 'is_search', 'is_single',
'is_singular', 'is_ssl', 'is_sticky', 'is_tag', 'is_tax', 'is_time', 'is_trackback', 'is_year'
) );
Expand Down
14 changes: 7 additions & 7 deletions components/db_callers.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

class QM_DB_Functions extends QM {
class QM_DB_Callers extends QM {

var $id = 'db_functions';
var $id = 'db_callers';

function __construct() {
parent::__construct();
Expand All @@ -22,7 +22,7 @@ function admin_menu( $menu ) {

if ( $dbq = $this->get_component( 'db_queries' ) and isset( $dbq->data['times'] ) ) {
$menu[] = $this->menu( array(
'title' => __( 'Query Functions', 'query-monitor' )
'title' => __( 'Query Callers', 'query-monitor' )
) );
}
return $menu;
Expand All @@ -41,7 +41,7 @@ function output( $args, $data ) {
echo '<table cellspacing="0">';
echo '<thead>';
echo '<tr>';
echo '<th>' . __( 'Query Function', 'query-monitor' ) . '</th>';
echo '<th>' . _x( 'Caller', 'Query caller', 'query-monitor' ) . '</th>';

if ( !empty( $data['types'] ) ) {
foreach ( $data['types'] as $type_name => $type_count )
Expand Down Expand Up @@ -104,11 +104,11 @@ function output( $args, $data ) {

}

function register_qm_db_functions( $qm ) {
$qm['db_functions'] = new QM_DB_Functions;
function register_qm_db_callers( $qm ) {
$qm['db_callers'] = new QM_DB_Callers;
return $qm;
}

add_filter( 'query_monitor_components', 'register_qm_db_functions', 30 );
add_filter( 'query_monitor_components', 'register_qm_db_callers', 30 );

?>
2 changes: 1 addition & 1 deletion components/db_components.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function output( $args, $data ) {
echo '<table cellspacing="0">';
echo '<thead>';
echo '<tr>';
echo '<th>' . __( 'Query Component', 'query-monitor' ) . '</th>';
echo '<th>' . _x( 'Component', 'Query component', 'query-monitor' ) . '</th>';

if ( !empty( $data['types'] ) ) {
foreach ( $data['types'] as $type_name => $type_count )
Expand Down
44 changes: 44 additions & 0 deletions components/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,48 @@ function __construct() {
$this->data['php']['variables'][$setting]['before'] = $val;
}

if ( isset( $wpdb->qm_php_vars['error_reporting'] ) )
$val = $wpdb->qm_php_vars['error_reporting'];
else
$val = implode( '<br/>', $this->get_error_reporting() );
$this->data['php']['variables']['error_reporting']['before'] = $val;

}

function get_error_reporting() {

$error_reporting = error_reporting();
$levels = array();

$constants = array(
'E_ERROR',
'E_WARNING',
'E_PARSE',
'E_NOTICE',
#'E_CORE_ERROR',
#'E_CORE_WARNING',
#'E_COMPILE_ERROR',
#'E_COMPILE_WARNING',
'E_USER_ERROR',
'E_USER_WARNING',
'E_USER_NOTICE',
'E_STRICT',
'E_RECOVERABLE_ERROR',
'E_DEPRECATED',
'E_USER_DEPRECATED',
'E_ALL'
);

foreach ( $constants as $level ) {
if ( defined( $level ) ) {
$c = constant( $level );
if ( $error_reporting & $c )
$levels[$c] = $level;
}
}

return $levels;

}

function admin_menu( $menu ) {
Expand Down Expand Up @@ -104,6 +146,8 @@ function process() {
foreach ( $this->php_vars as $setting )
$this->data['php']['variables'][$setting]['after'] = ini_get( $setting );

$this->data['php']['variables']['error_reporting']['after'] = implode( '<br/>', $this->get_error_reporting() );

$wp_debug = ( WP_DEBUG ) ? 'ON' : 'OFF';

$this->data['wp'] = array(
Expand Down
10 changes: 1 addition & 9 deletions components/query_vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,7 @@ function output( $args, $data ) {
$var = '<span class="qm-current">' . $var . '</span>';
echo '<tr>';
echo "<td valign='top'>{$var}</td>";
if ( is_array( $value ) ) {
echo '<td valign="top"><ul>';
foreach ( $value as $k => $v ) {
$k = esc_html( $k );
$v = esc_html( $v );
echo "<li>{$k} => {$v}</li>";
}
echo '</ul></td>';
} else if ( is_object( $value ) ) {
if ( is_array( $value ) or is_object( $value ) ) {
echo '<td valign="top"><pre>';
print_r( $value );
echo '</pre></td>';
Expand Down
17 changes: 11 additions & 6 deletions query-monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Query Monitor
Description: Monitoring of database queries, hooks, conditionals and more.
Version: 2.2.6
Version: 2.2.7b
Author: John Blackbourn
Author URI: http://lud.icro.us/
Text Domain: query-monitor
Expand Down Expand Up @@ -39,18 +39,20 @@
@ TODO:
* Display queries from page loads before wp_redirect()
* Log and display queries from page loads before wp_redirect()
* Display queries from AJAX calls
* Show queried object info
* Show hooks attached to some selected filters, eg request, parse_request
* Add 'Component' filter to PHP errors list
* Change 'Function' to 'Caller'
* Correctly show theme template used when using BuddyPress
* Ignore dbDelta() in caller list
*/

class QueryMonitor {

var $components = array();

function __construct() {

# Actions
Expand Down Expand Up @@ -80,12 +82,12 @@ function __construct() {
}

function add_component( $component ) {
$this->components->{$component->id} = $component;
$this->components[$component->id] = $component;
}

function get_component( $id ) {
if ( isset( $this->components->$id ) )
return $this->components->$id;
if ( isset( $this->components[$id] ) )
return $this->components[$id];
return false;
}

Expand Down Expand Up @@ -178,6 +180,9 @@ function js_admin_bar_menu() {

function show_query_monitor() {

if ( isset( $_REQUEST['wp_customize'] ) and 'on' == $_REQUEST['wp_customize'] )
return false;

if ( $this->is_multisite ) {
if ( current_user_can( 'manage_network_options' ) )
return true;
Expand Down

0 comments on commit 9c9572c

Please sign in to comment.