PluginProbe
WP Debugging / 2.11.13
WP Debugging v2.11.13
2.12.6 2.12.5 trunk 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.11.10 2.11.11 2.11.12 2.11.13 2.11.14 2.11.15 2.11.16 2.11.17 2.11.18 2.11.19 2.11.2 2.11.20 2.11.21 2.11.22 2.11.23 2.11.24 2.11.3 All 59 releases
wp-debugging / vendor / norcross / debug-quick-look / includes / admin-bar.php

admin-bar.php in WP Debugging 2.11.13, at vendor/norcross/debug-quick-look/includes/admin-bar.php

145 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle the admin bar setup.
4 *
5 * @package DebugQuickLook
6 */
7
8 // Call our namepsace.
9 namespace DebugQuickLook\AdminBar;
10
11 // Set our alias items.
12 use DebugQuickLook as Core;
13 use DebugQuickLook\Helpers as Helpers;
14
15 /**
16 * Start our engines.
17 */
18 add_action( 'wp_head', __NAMESPACE__ . '\add_warning_css' );
19 add_action( 'admin_head', __NAMESPACE__ . '\add_warning_css' );
20 add_action( 'wp_head', __NAMESPACE__ . '\add_mobile_css' );
21 add_action( 'admin_head', __NAMESPACE__ . '\add_mobile_css' );
22 add_action( 'admin_bar_menu', __NAMESPACE__ . '\admin_bar_links', 9999 );
23
24 /**
25 * Add the CSS to flag our warning message.
26 */
27 function add_warning_css() {
28
29 // Run my cap check.
30 $hascap = Helpers\check_user_cap( 'warning-css' );
31
32 // Bail without.
33 if ( ! $hascap ) {
34 return;
35 }
36
37 // Open the style tag.
38 echo '<style>';
39
40 // Output the actual CSS item.
41 echo 'li#wp-admin-bar-debug-quick-look li.debug-quick-look-missing .ab-item span {';
42 echo 'color: #ff0000;';
43 echo 'font-weight: bold;';
44 echo 'font-family: Consolas, Monaco, monospace;';
45 echo '}';
46
47 // Close the style tag.
48 echo '</style>';
49 }
50
51 /**
52 * Add the links for the debug log file.
53 *
54 * @param WP_Admin_Bar $wp_admin_bar The global WP_Admin_Bar object.
55 *
56 * @return void.
57 */
58 function admin_bar_links( $wp_admin_bar ) {
59
60 // Run my cap check.
61 $hascap = Helpers\check_user_cap( 'admin-bar' );
62
63 // Bail without.
64 if ( ! $hascap ) {
65 return;
66 }
67
68 // Fetch my nodes.
69 $nodes = Helpers\get_admin_bar_nodes();
70
71 // Bail without nodes.
72 if ( ! $nodes ) {
73 return;
74 }
75
76 // Add a parent item.
77 $wp_admin_bar->add_node(
78 array(
79 'id' => 'debug-quick-look',
80 'title' => __( 'Debug Quick Look', 'debug-quick-look' ),
81 )
82 );
83
84 // Check to see if we have our constant.
85 $hascon = Helpers\maybe_constant_set();
86
87 // If no constant is set, show the error.
88 if ( ! $hascon ) {
89
90 // Show the error node.
91 $wp_admin_bar->add_node( $nodes['error'] );
92
93 // And be done.
94 return;
95 }
96
97 // We have the constant, so unset the error.
98 unset( $nodes['error'] );
99
100 // Loop my node data.
101 foreach ( $nodes as $node_name => $node_data ) {
102 $wp_admin_bar->add_node( $node_data );
103 }
104
105 // And be done.
106 return;
107 }
108
109 /**
110 * Add the CSS to add admin bar menu on mobile.
111 */
112 function add_mobile_css() {
113
114 // Run my cap check.
115 $hascap = Helpers\check_user_cap( 'warning-css' );
116
117 // Bail without.
118 if ( ! $hascap ) {
119 return;
120 }
121
122 // Open the style tag.
123 echo '<style>';
124
125 // Output the actual CSS item.
126 echo '@media screen and (max-width: 782px) {';
127 echo '#wp-toolbar > ul > li#wp-admin-bar-debug-quick-look {';
128 // Style similar to Query Monitor.
129 echo 'display: list-item;';
130 echo 'font: 18px/44px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;';
131 echo 'padding: 0 10px !important;';
132 echo 'width: auto !important';
133 echo '}';
134 echo '#wp-toolbar > ul > li#wp-admin-bar-debug-quick-look:before {';
135 echo 'content: "DQL";';
136 echo '}';
137 echo '#wp-toolbar > ul > li#wp-admin-bar-debug-quick-look div.ab-item.ab-empty-item {';
138 echo 'display: none;';
139 echo '}';
140 echo '}';
141
142 // Close the style tag.
143 echo '</style>';
144 }
145