-
Notifications
You must be signed in to change notification settings - Fork 3
/
QM_Collector_WPBP_Debug_Output.php
71 lines (62 loc) · 1.65 KB
/
QM_Collector_WPBP_Debug_Output.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
<?php
class QM_Collector_WPBP_Debug_Output extends QM_Output_Html {
public $title;
public $parent;
public function __construct( QM_Collector $collector, $output, $title ) {
parent::__construct( $collector );
$this->output = $output;
$this->title = $title;
$this->id = strtolower( str_replace(' ', '-', $title ) );
add_filter( 'qm/output/menus', array( $this, 'admin_menu' ), 101 );
add_filter( 'qm/output/title', array( $this, 'admin_title' ), 101 );
add_filter( 'qm/output/menu_class', array( $this, 'admin_class' ) );
}
/**
* Outputs data in the footer
*/
public function output() {
if ( is_array( $this->output ) ) {
echo '<div class="qm" id="' . esc_attr($this->collector->id()) . '">';
echo '<table cellspacing="0"><tbody>';
foreach ( $this->output as &$single ) {
echo "<tr><td>" . $single . "</td></tr>";
}
echo '</tbody></table>';
echo '</div>';
}
}
/**
* Adds data to top admin bar
*
* @param array $title
*
* @return array
*/
public function admin_title( array $title ) {
$data = $this->collector->get_data();
if ( isset( $data['log'] ) ) {
$title[] = $this->title . ' (' . count( $data['log'] ) . ')';
}
return $title;
}
/**
* @param array $class
*
* @return array
*/
public function admin_class( array $class ) {
$class[] = $this->id;
return $class;
}
public function admin_menu( array $menu ) {
$data = $this->collector->get_data();
if ( isset( $data['log'] ) ) {
$menu[] = $this->menu( array(
'id' => $this->id,
'href' => '#qm-' . str_replace( '_', '-', $this->id),
'title' => $this->title . ' (' . count( $data['log'] ) . ')'
));
}
return $menu;
}
}