-
Notifications
You must be signed in to change notification settings - Fork 2
/
scb-debug.php
103 lines (81 loc) · 1.9 KB
/
scb-debug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
function dpb() {
echo '<pre>';
debug_print_backtrace();
echo '</pre>';
}
// Example: add_filter( 'posts_request', '__debug_filter' );
function __debug_filter( $val ) {
debug( func_get_args() );
return $val;
}
// See the list of callbacks attached to a certain filter
function debug_filters( $tag = false ) {
global $wp_filter;
if ( $tag ) {
$hook[ $tag ] = $wp_filter[ $tag ];
if ( !is_array( $hook[ $tag ] ) ) {
trigger_error("Nothing found for '$tag' hook", E_USER_NOTICE);
return;
}
}
else {
$hook = $wp_filter;
ksort( $hook );
}
echo '<pre>';
foreach ( $hook as $tag => $priority ) {
echo "<br />>>>>>\t<strong>$tag</strong><br />";
ksort( $priority );
foreach ( $priority as $priority => $function ) {
echo $priority;
foreach( $function as $name => $properties )
echo "\t$name<br>\n";
}
}
echo '</pre>';
}
function debug() {
$args = func_get_args();
echo defined('DOING_AJAX') ? "\n" : "<pre>";
foreach ( $args as $arg ) {
if ( is_array($arg) || is_object($arg) )
print_r($arg);
else
var_dump($arg);
}
echo defined('DOING_AJAX') ? "\n" : "</pre>";
}
function debug_k() {
call_user_func_array( 'debug', func_get_args() );
die;
}
// Debug, only if current user is an administrator
function debug_a() {
if ( !current_user_can('administrator') )
return;
$args = func_get_args();
call_user_func_array( 'debug', $args );
}
// Debug last executed SQL query
function debug_lq() {
global $wpdb;
debug($wpdb->last_query);
}
// Debug WP_Query is_* flags
function debug_qf( $wp_query = null ) {
debug( implode( ' ', scb_get_query_flags( $wp_query ) ) );
}
// Debug cron entries
function debug_cron() {
add_action('admin_footer', '_debug_cron');
}
function _debug_cron() {
debug(get_option('cron'));
}
// Debug timestamps
function debug_ts() {
$args = func_get_args();
foreach ( $args as $arg )
debug( date( 'Y-m-d H:i', $arg ) );
}