forked from Automattic/vip-go-mu-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug-bar.php
57 lines (46 loc) · 1.76 KB
/
debug-bar.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
<?php
/*
Plugin Name: Debug Bar
Plugin URI: https://wordpress.org/plugins/debug-bar/
Description: Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
Author: wordpressdotorg
Version: 0.9
Author URI: https://wordpress.org/
Text Domain: debug-bar
*/
add_filter( 'debug_bar_enable', function( $enable ) {
$enable = is_automattician();
return $enable;
}, 99 );
// We only need to load the files if it's enabled
add_action( 'init', function() {
$enable = apply_filters( 'debug_bar_enable', false );
if ( ! $enable ) {
return;
}
require_once( __DIR__ . '/debug-bar/debug-bar.php' );
// Load additional plugins
if ( ! class_exists( 'ZT_Debug_Bar_Cron' ) ) {
require_once( __DIR__ . '/debug-bar-cron/debug-bar-cron.php' );
}
// Setup extra panels
add_filter( 'debug_bar_panels', function( $panels ) {
require_once( __DIR__ . '/vip-helpers/vip-debug-bar-panels.php' );
require_once( __DIR__ . '/debug-bar/panels/class-debug-bar-elasticsearch.php' );
$total = count( $panels );
for ( $i = 0; $i < $total; $i++) {
if ( $panels[ $i ] instanceof Debug_Bar_Queries && function_exists( 'wpcom_vip_save_query_callback' ) ) {
$panels[ $i ] = new WPCOM_VIP_Debug_Bar_Queries();
} elseif ( $panels[ $i ] instanceof Debug_Bar_Object_Cache ) {
$panels[ $i ] = new WPCOM_VIP_Debug_Bar_Memcached();
} elseif ( $panels[ $i ] instanceof Debug_Bar_PHP ) {
$panels[ $i ] = new WPCOM_VIP_Debug_Bar_PHP();
}
}
$panels[] = new WPCOM_VIP_Debug_Bar_Query_Summary();
$panels[] = new WPCOM_VIP_Debug_Bar_DB_Connections();
$panels[] = new WPCOM_VIP_Debug_Bar_Remote_Requests();
$panels[] = new Debug_Bar_Elasticsearch();
return $panels;
}, 99);
}, 1 ); // Priority must be lower than that of Query Monitor