/var/www/html_it/wp-content/plugins/query-monitor/collectors/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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php declare(strict_types 1);
/**
 * Mock 'Debug Bar' data collector.
 *
 * @package query-monitor
 */

if ( ! defined'ABSPATH' ) ) {
    exit;
}

final class 
QM_Collector_Debug_Bar extends QM_Collector {

    
/**
     * @var string
     */
    
public $id 'debug_bar';

    
/**
     * @var Debug_Bar_Panel|null
     */
    
private $panel null;

    
/**
     * @param Debug_Bar_Panel $panel
     * @return void
     */
    
public function set_panelDebug_Bar_Panel $panel ) {
        
$this->panel $panel;
    }

    
/**
     * @return Debug_Bar_Panel|null
     */
    
public function get_panel() {
        return 
$this->panel;
    }

    
/**
     * @return void
     */
    
public function process() {
        
$this->get_panel()->prerender();
    }

    
/**
     * @return bool
     */
    
public function is_visible() {
        return 
$this->get_panel()->is_visible();
    }

    
/**
     * @return void
     */
    
public function render() {
        
$this->get_panel()->render();
    }

}

/**
 * @return void
 */
function register_qm_collectors_debug_bar() {

    global 
$debug_bar;

    
$debug_bar_exists = isset( $GLOBALS['debug_bar'] ) && ( $GLOBALS['debug_bar'] instanceof Debug_Bar );

    if ( 
$debug_bar_exists || qm_debug_bar_being_activated() ) {
        return;
    }

    
$collectors QM_Collectors::init();

    
$debug_bar = new Debug_Bar();
    
$redundant = array(
        
'debug_bar_actions_addon_panel'// Debug Bar Actions and Filters Addon
        
'debug_bar_remote_requests_panel'// Debug Bar Remote Requests
        
'debug_bar_screen_info_panel'// Debug Bar Screen Info
        
'ps_listdeps_debug_bar_panel'// Debug Bar List Script & Style Dependencies
    
);

    foreach ( 
$debug_bar->panels as $panel ) {
        
$panel_id strtolowersanitize_html_classget_class$panel ) ) );

        if ( 
in_array$panel_id$redundanttrue ) ) {
            continue;
        }

        
$collector = new QM_Collector_Debug_Bar();
        
$collector->set_id"debug_bar_{$panel_id});
        
$collector->set_panel$panel );

        
$collectors->add$collector );
    }

}

/**
 * @return bool
 */
function qm_debug_bar_being_activated() {
    
// phpcs:disable

    
if ( ! is_admin() ) {
        return 
false;
    }

    if ( ! isset( 
$_REQUEST['action'] ) ) {
        return 
false;
    }

    if ( isset( 
$_GET['action'] ) ) {

        if ( ! isset( 
$_GET['plugin'] ) || ! isset( $_GET['_wpnonce'] ) ) {
            return 
false;
        }

        if ( 
'activate' === $_GET['action'] && false !== strposwp_unslash$_GET['plugin'] ), 'debug-bar.php' ) ) {
            return 
true;
        }

    } elseif ( isset( 
$_POST['action'] ) ) {

        if ( ! isset( 
$_POST['checked'] ) || ! is_array$_POST['checked'] ) || ! isset( $_POST['_wpnonce'] ) ) {
            return 
false;
        }

        if ( 
'activate-selected' === wp_unslash$_POST['action'] ) && in_array'debug-bar/debug-bar.php'wp_unslash$_POST['checked'] ), true ) ) {
            return 
true;
        }

    }

    return 
false;
    
// phpcs:enable
}

add_action'init''register_qm_collectors_debug_bar' );