-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathefc-debug-include.php
65 lines (51 loc) · 1.58 KB
/
efc-debug-include.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
<?php
/*
efc-debug-include.php
If you want to be able to create messages for the debug menu
from your functions.php file, then include this script early in
functions.php with...
include_once(dirname(__FILE__).'/../../plugins/efc-debug/efc-debug-include.php');
...assuming standard WordPress directory structure.
Then you will be able to add messages to the Debug Report with...
if (function_exists('dbug_report')) dbug_report('message: ',$variable);
*/
if ( ! function_exists('dbug_report') ) {
function dbug_report() {
global $dbug_note;
global $dbug_array;
if (! isset($dbug_note) ) {
$dbug_note = '';
add_action('wp_footer', 'dbug_report_in_footer', 9999);
}
$out = '';
$m = func_get_args();
foreach($m as $message) {
if ( is_string($message) ) {
$out .= $message;
$dbug_array[] = '<p>'.htmlspecialchars($message).'</p>';
} else {
$message = print_r($message, true);
$out .= $message;
$dbug_array[] = '<pre>'.htmlspecialchars($message).'</pre>';
}
}
$dbug_note .= "\n" . $out;
}
function dbug_report_in_footer() {
global $dbug_note;
global $dbug_array;
global $DBug;
global $wp_query;
if (is_object($DBug)) {
$DBug->add('<h2>Debug Report</h2>');
foreach ( $dbug_array as $message ) {
$DBug->add($message);
echo '<!-- ' . str_replace('-->', '==>', $message ) . "-->\n";
}
$DBug->add('<h2>$wp_query</h2>');
$DBug->add('<pre>'.htmlspecialchars(print_r($wp_query,true)).'</pre>');
$DBug->add('<h2>$_ENV</h2>');
$DBug->add('<pre>'.htmlspecialchars(print_r($_ENV,true)).'</pre>');
}
}
}