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
|
<?php declare(strict_types = 1); /** * Mock 'Debug Bar' plugin class. * * @package query-monitor */
class Debug_Bar { /** * @var array<int, Debug_Bar_Panel> */ public $panels = array();
public function __construct() { add_action( 'wp_head', array( $this, 'ensure_ajaxurl' ), 1 );
$this->enqueue(); $this->init_panels(); }
/** * @return void */ public function enqueue() { // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion wp_register_style( 'debug-bar', false, array( 'query-monitor', ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion wp_register_script( 'debug-bar', false, array( 'query-monitor', ) );
/** * Fires after scripts have been enqueued. This mimics the same action fired in the Debug Bar plugin. * * @since 2.7.0 */ do_action( 'debug_bar_enqueue_scripts' ); }
/** * @return void */ public function init_panels() { /** * Filters the debug bar panel list. This mimics the same filter called in the Debug Bar plugin. * * @since 2.7.0 * * @param array<int, Debug_Bar_Panel> $panels Array of Debug Bar panel instances. */ $this->panels = apply_filters( 'debug_bar_panels', array() ); }
/** * @return void */ public function ensure_ajaxurl() { $dispatcher = QM_Dispatchers::get( 'html' );
if ( $this->panels && $dispatcher && $dispatcher::user_can_view() ) { wp_print_inline_script_tag( sprintf( "var ajaxurl = '%s';", esc_url_raw( admin_url( 'admin-ajax.php' ) ) ), array( 'id' => 'query-monitor-inline-debug-bar', ) ); } }
/** * @return void */ public function Debug_Bar() { self::__construct(); }
}
|