-
Notifications
You must be signed in to change notification settings - Fork 5
/
qm-memcache-stats.php
57 lines (47 loc) · 1.19 KB
/
qm-memcache-stats.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: Query Monitor: Memcache Stats
* Description: Shows Memcache stats in Query Monitor
* Version: 0.1
* Plugin URI: https://github.com/Automattic/qm-memcache-stats
* Author: Automattic
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Class QM_Collector_Memcache
*/
class QM_Memcache_Stats {
public function __construct() {
if ( class_exists( 'QM_Collectors' ) ) {
$this->register_collector();
add_filter( 'qm/outputter/html', array( $this, 'register_output' ), 101, 1 );
}
}
/*
* Register collector
*
* @return void
*/
private function register_collector() {
require_once( 'classes/QM_Collector_Memcache_Stats.php' );
QM_Collectors::add( new QM_Collector_Memcache_Stats() );
}
/*
* Register output
*
* @param array $output
*
* @return array
*/
public function register_output( $output ) {
require_once( 'classes/QM_Output_Memcache_Stats.php' );
if ( $collector = QM_Collectors::get( 'memcache-stats' ) ) {
$output['memcache'] = new QM_Output_Memcache_Stats( $collector );
}
return $output;
}
}
add_action( 'plugins_loaded', function () {
new QM_Memcache_Stats();
}, 10, 0 );