run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄admin-bar.php
1<?php
2/**
3 * Toolbar API: Top-level Toolbar functionality
4 *
5 * @package WordPress
6 * @subpackage Toolbar
7 * @since 3.1.0
8 */
9
10/**
11 * Instantiates the admin bar object and set it up as a global for access elsewhere.
12 *
13 * UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR.
14 * For that, use show_admin_bar(false) or the {@see 'show_admin_bar'} filter.
15 *
16 * @since 3.1.0
17 * @access private
18 *
19 * @global WP_Admin_Bar $wp_admin_bar
20 *
21 * @return bool Whether the admin bar was successfully initialized.
22 */
23function _wp_admin_bar_init() {
24 global $wp_admin_bar;
25
26 if ( ! is_admin_bar_showing() ) {
27 return false;
28 }
29
30 /* Load the admin bar class code ready for instantiation */
31 require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
32
33 /* Instantiate the admin bar */
34
35 /**
36 * Filters the admin bar class to instantiate.
37 *
38 * @since 3.1.0
39 *
40 * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
41 */
42 $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
43 if ( class_exists( $admin_bar_class ) ) {
44 $wp_admin_bar = new $admin_bar_class();
45 } else {
46 return false;
47 }
48
49 $wp_admin_bar->initialize();
50 $wp_admin_bar->add_menus();
51
52 return true;
53}
54
55/**
56 * Renders the admin bar to the page based on the $wp_admin_bar->menu member var.
57 *
58 * This is called very early on the {@see 'wp_body_open'} action so that it will render
59 * before anything else being added to the page body.
60 *
61 * For backward compatibility with themes not using the 'wp_body_open' action,
62 * the function is also called late on {@see 'wp_footer'}.
63 *
64 * It includes the {@see 'admin_bar_menu'} action which should be used to hook in and
65 * add new menus to the admin bar. This also gives you access to the `$post` global,
66 * among others.
67 *
68 * @since 3.1.0
69 * @since 5.4.0 Called on 'wp_body_open' action first, with 'wp_footer' as a fallback.
70 *
71 * @global WP_Admin_Bar $wp_admin_bar
72 */
73function wp_admin_bar_render() {
74 global $wp_admin_bar;
75 static $rendered = false;
76
77 if ( $rendered ) {
78 return;
79 }
80
81 if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
82 return;
83 }
84
85 /**
86 * Loads all necessary admin bar items.
87 *
88 * This hook can add, remove, or manipulate admin bar items. The priority
89 * determines the placement for new items, and changes to existing items
90 * would require a high priority. To remove or manipulate existing nodes
91 * without a specific priority, use `wp_before_admin_bar_render`.
92 *
93 * @since 3.1.0
94 *
95 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
96 */
97 do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
98
99 /**
100 * Fires before the admin bar is rendered.
101 *
102 * @since 3.1.0
103 */
104 do_action( 'wp_before_admin_bar_render' );
105
106 $wp_admin_bar->render();
107
108 /**
109 * Fires after the admin bar is rendered.
110 *
111 * @since 3.1.0
112 */
113 do_action( 'wp_after_admin_bar_render' );
114
115 $rendered = true;
116}
117
118/**
119 * Adds the WordPress logo menu.
120 *
121 * @since 3.3.0
122 *
123 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
124 */
125function wp_admin_bar_wp_menu( $wp_admin_bar ) {
126 if ( current_user_can( 'read' ) ) {
127 $about_url = self_admin_url( 'about.php' );
128 $contribute_url = self_admin_url( 'contribute.php' );
129 } elseif ( is_multisite() ) {
130 $about_url = get_dashboard_url( get_current_user_id(), 'about.php' );
131 $contribute_url = get_dashboard_url( get_current_user_id(), 'contribute.php' );
132 } else {
133 $about_url = false;
134 $contribute_url = false;
135 }
136
137 $wp_logo_menu_args = array(
138 'id' => 'wp-logo',
139 'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' .
140 /* translators: Hidden accessibility text. */
141 __( 'About WordPress' ) .
142 '</span>',
143 'href' => $about_url,
144 'meta' => array(
145 'menu_title' => __( 'About WordPress' ),
146 ),
147 );
148
149 // Set tabindex="0" to make sub menus accessible when no URL is available.
150 if ( ! $about_url ) {
151 $wp_logo_menu_args['meta'] = array(
152 'tabindex' => 0,
153 );
154 }
155
156 $wp_admin_bar->add_node( $wp_logo_menu_args );
157
158 if ( $about_url ) {
159 // Add "About WordPress" link.
160 $wp_admin_bar->add_node(
161 array(
162 'parent' => 'wp-logo',
163 'id' => 'about',
164 'title' => __( 'About WordPress' ),
165 'href' => $about_url,
166 )
167 );
168 }
169
170 if ( $contribute_url ) {
171 // Add contribute link.
172 $wp_admin_bar->add_node(
173 array(
174 'parent' => 'wp-logo',
175 'id' => 'contribute',
176 'title' => __( 'Get Involved' ),
177 'href' => $contribute_url,
178 )
179 );
180 }
181
182 // Add WordPress.org link.
183 $wp_admin_bar->add_node(
184 array(
185 'parent' => 'wp-logo-external',
186 'id' => 'wporg',
187 'title' => __( 'WordPress.org' ),
188 'href' => __( 'https://wordpress.org/' ),
189 )
190 );
191
192 // Add documentation link.
193 $wp_admin_bar->add_node(
194 array(
195 'parent' => 'wp-logo-external',
196 'id' => 'documentation',
197 'title' => __( 'Documentation' ),
198 'href' => __( 'https://wordpress.org/documentation/' ),
199 )
200 );
201
202 // Add learn link.
203 $wp_admin_bar->add_node(
204 array(
205 'parent' => 'wp-logo-external',
206 'id' => 'learn',
207 'title' => __( 'Learn WordPress' ),
208 'href' => __( 'https://learn.wordpress.org/' ),
209 )
210 );
211
212 // Add forums link.
213 $wp_admin_bar->add_node(
214 array(
215 'parent' => 'wp-logo-external',
216 'id' => 'support-forums',
217 'title' => __( 'Support' ),
218 'href' => __( 'https://wordpress.org/support/forums/' ),
219 )
220 );
221
222 // Add feedback link.
223 $wp_admin_bar->add_node(
224 array(
225 'parent' => 'wp-logo-external',
226 'id' => 'feedback',
227 'title' => __( 'Feedback' ),
228 'href' => __( 'https://wordpress.org/support/forum/requests-and-feedback' ),
229 )
230 );
231}
232
233/**
234 * Adds the sidebar toggle button.
235 *
236 * @since 3.8.0
237 *
238 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
239 */
240function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
241 if ( is_admin() ) {
242 $wp_admin_bar->add_node(
243 array(
244 'id' => 'menu-toggle',
245 'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' .
246 /* translators: Hidden accessibility text. */
247 __( 'Menu' ) .
248 '</span>',
249 'href' => '#',
250 )
251 );
252 }
253}
254
255/**
256 * Adds the "My Account" item.
257 *
258 * @since 3.3.0
259 *
260 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
261 */
262function wp_admin_bar_my_account_item( $wp_admin_bar ) {
263 $user_id = get_current_user_id();
264 if ( ! $user_id ) {
265 return;
266 }
267
268 if ( current_user_can( 'read' ) ) {
269 $profile_url = get_edit_profile_url( $user_id );
270 } elseif ( is_multisite() ) {
271 $profile_url = get_dashboard_url( $user_id, 'profile.php' );
272 } else {
273 $profile_url = false;
274 }
275
276 /* translators: %s: Current user's display name. */
277 $howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . wp_get_current_user()->display_name . '</span>' );
278
279 $avatar = get_avatar( $user_id, 26 );
280 $wp_admin_bar->add_node(
281 array(
282 'id' => 'my-account',
283 'parent' => 'top-secondary',
284 'title' => $howdy . $avatar,
285 'href' => $profile_url,
286 'meta' => array(
287 'class' => empty( $avatar ) ? '' : 'with-avatar',
288 'menu_title' => wp_strip_all_tags( $howdy ),
289 'tabindex' => ( false !== $profile_url ) ? '' : 0,
290 ),
291 )
292 );
293}
294
295/**
296 * Adds the "My Account" submenu items.
297 *
298 * @since 3.1.0
299 *
300 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
301 */
302function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
303 $user_id = get_current_user_id();
304 $current_user = wp_get_current_user();
305
306 if ( ! $user_id ) {
307 return;
308 }
309
310 if ( current_user_can( 'read' ) ) {
311 $profile_url = get_edit_profile_url( $user_id );
312 } elseif ( is_multisite() ) {
313 $profile_url = get_dashboard_url( $user_id, 'profile.php' );
314 } else {
315 $profile_url = false;
316 }
317
318 $wp_admin_bar->add_group(
319 array(
320 'parent' => 'my-account',
321 'id' => 'user-actions',
322 )
323 );
324
325 $user_info = get_avatar( $user_id, 64 );
326 $user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
327
328 if ( $current_user->display_name !== $current_user->user_login ) {
329 $user_info .= "<span class='username'>{$current_user->user_login}</span>";
330 }
331
332 if ( false !== $profile_url ) {
333 $user_info .= "<span class='display-name edit-profile'>" . __( 'Edit Profile' ) . '</span>';
334 }
335
336 $wp_admin_bar->add_node(
337 array(
338 'parent' => 'user-actions',
339 'id' => 'user-info',
340 'title' => $user_info,
341 'href' => $profile_url,
342 )
343 );
344
345 $wp_admin_bar->add_node(
346 array(
347 'parent' => 'user-actions',
348 'id' => 'logout',
349 'title' => __( 'Log Out' ),
350 'href' => wp_logout_url(),
351 )
352 );
353}
354
355/**
356 * Adds the "Site Name" menu.
357 *
358 * @since 3.3.0
359 *
360 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
361 */
362function wp_admin_bar_site_menu( $wp_admin_bar ) {
363 // Don't show for logged out users.
364 if ( ! is_user_logged_in() ) {
365 return;
366 }
367
368 // Show only when the user is a member of this site, or they're a super admin.
369 if ( ! is_user_member_of_blog() && ! current_user_can( 'manage_network' ) ) {
370 return;
371 }
372
373 $blogname = get_bloginfo( 'name' );
374
375 if ( ! $blogname ) {
376 $blogname = preg_replace( '#^(https?://)?(www\.)?#', '', get_home_url() );
377 }
378
379 if ( is_network_admin() ) {
380 /* translators: %s: Site title. */
381 $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
382 } elseif ( is_user_admin() ) {
383 /* translators: %s: Site title. */
384 $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
385 }
386
387 $title = wp_html_excerpt( $blogname, 40, '&hellip;' );
388
389 $wp_admin_bar->add_node(
390 array(
391 'id' => 'site-name',
392 'title' => $title,
393 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
394 'meta' => array(
395 'menu_title' => $title,
396 ),
397 )
398 );
399
400 // Create submenu items.
401
402 if ( is_admin() ) {
403 // Add an option to visit the site.
404 $wp_admin_bar->add_node(
405 array(
406 'parent' => 'site-name',
407 'id' => 'view-site',
408 'title' => __( 'Visit Site' ),
409 'href' => home_url( '/' ),
410 )
411 );
412
413 if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) {
414 $wp_admin_bar->add_node(
415 array(
416 'parent' => 'site-name',
417 'id' => 'edit-site',
418 'title' => __( 'Manage Site' ),
419 'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ),
420 )
421 );
422 }
423 } elseif ( current_user_can( 'read' ) ) {
424 // We're on the front end, link to the Dashboard.
425 $wp_admin_bar->add_node(
426 array(
427 'parent' => 'site-name',
428 'id' => 'dashboard',
429 'title' => __( 'Dashboard' ),
430 'href' => admin_url(),
431 )
432 );
433
434 // Add the appearance submenu items.
435 wp_admin_bar_appearance_menu( $wp_admin_bar );
436
437 // Add a Plugins link.
438 if ( current_user_can( 'activate_plugins' ) ) {
439 $wp_admin_bar->add_node(
440 array(
441 'parent' => 'site-name',
442 'id' => 'plugins',
443 'title' => __( 'Plugins' ),
444 'href' => admin_url( 'plugins.php' ),
445 )
446 );
447 }
448 }
449}
450
451/**
452 * Adds the "Edit Site" link to the Toolbar.
453 *
454 * @since 5.9.0
455 * @since 6.3.0 Added `$_wp_current_template_id` global for editing of current template directly from the admin bar.
456 * @since 6.6.0 Added the `canvas` query arg to the Site Editor link.
457 *
458 * @global string $_wp_current_template_id
459 *
460 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
461 */
462function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
463 global $_wp_current_template_id;
464
465 // Don't show if a block theme is not activated.
466 if ( ! wp_is_block_theme() ) {
467 return;
468 }
469
470 // Don't show for users who can't edit theme options or when in the admin.
471 if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
472 return;
473 }
474
475 $wp_admin_bar->add_node(
476 array(
477 'id' => 'site-editor',
478 'title' => __( 'Edit Site' ),
479 'href' => add_query_arg(
480 array(
481 'postType' => 'wp_template',
482 'postId' => $_wp_current_template_id,
483 'canvas' => 'edit',
484 ),
485 admin_url( 'site-editor.php' )
486 ),
487 )
488 );
489}
490
491/**
492 * Adds the "Customize" link to the Toolbar.
493 *
494 * @since 4.3.0
495 *
496 * @global WP_Customize_Manager $wp_customize
497 *
498 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
499 */
500function wp_admin_bar_customize_menu( $wp_admin_bar ) {
501 global $wp_customize;
502
503 // Don't show if a block theme is activated and no plugins use the customizer.
504 if ( wp_is_block_theme() && ! has_action( 'customize_register' ) ) {
505 return;
506 }
507
508 // Don't show for users who can't access the customizer or when in the admin.
509 if ( ! current_user_can( 'customize' ) || is_admin() ) {
510 return;
511 }
512
513 // Don't show if the user cannot edit a given customize_changeset post currently being previewed.
514 if ( is_customize_preview() && $wp_customize->changeset_post_id()
515 && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() )
516 ) {
517 return;
518 }
519
520 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
521 if ( is_customize_preview() && $wp_customize->changeset_uuid() ) {
522 $current_url = remove_query_arg( 'customize_changeset_uuid', $current_url );
523 }
524
525 $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
526 if ( is_customize_preview() ) {
527 $customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $customize_url );
528 }
529
530 $wp_admin_bar->add_node(
531 array(
532 'id' => 'customize',
533 'title' => __( 'Customize' ),
534 'href' => $customize_url,
535 'meta' => array(
536 'class' => 'hide-if-no-customize',
537 ),
538 )
539 );
540 add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
541}
542
543/**
544 * Adds the "My Sites/[Site Name]" menu and all submenus.
545 *
546 * @since 3.1.0
547 *
548 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
549 */
550function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
551 // Don't show for logged out users or single site mode.
552 if ( ! is_user_logged_in() || ! is_multisite() ) {
553 return;
554 }
555
556 // Show only when the user has at least one site, or they're a super admin.
557 if ( count( $wp_admin_bar->user->blogs ) < 1 && ! current_user_can( 'manage_network' ) ) {
558 return;
559 }
560
561 if ( $wp_admin_bar->user->active_blog ) {
562 $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' );
563 } else {
564 $my_sites_url = admin_url( 'my-sites.php' );
565 }
566
567 $wp_admin_bar->add_node(
568 array(
569 'id' => 'my-sites',
570 'title' => __( 'My Sites' ),
571 'href' => $my_sites_url,
572 )
573 );
574
575 if ( current_user_can( 'manage_network' ) ) {
576 $wp_admin_bar->add_group(
577 array(
578 'parent' => 'my-sites',
579 'id' => 'my-sites-super-admin',
580 )
581 );
582
583 $wp_admin_bar->add_node(
584 array(
585 'parent' => 'my-sites-super-admin',
586 'id' => 'network-admin',
587 'title' => __( 'Network Admin' ),
588 'href' => network_admin_url(),
589 )
590 );
591
592 $wp_admin_bar->add_node(
593 array(
594 'parent' => 'network-admin',
595 'id' => 'network-admin-d',
596 'title' => __( 'Dashboard' ),
597 'href' => network_admin_url(),
598 )
599 );
600
601 if ( current_user_can( 'manage_sites' ) ) {
602 $wp_admin_bar->add_node(
603 array(
604 'parent' => 'network-admin',
605 'id' => 'network-admin-s',
606 'title' => __( 'Sites' ),
607 'href' => network_admin_url( 'sites.php' ),
608 )
609 );
610 }
611
612 if ( current_user_can( 'manage_network_users' ) ) {
613 $wp_admin_bar->add_node(
614 array(
615 'parent' => 'network-admin',
616 'id' => 'network-admin-u',
617 'title' => __( 'Users' ),
618 'href' => network_admin_url( 'users.php' ),
619 )
620 );
621 }
622
623 if ( current_user_can( 'manage_network_themes' ) ) {
624 $wp_admin_bar->add_node(
625 array(
626 'parent' => 'network-admin',
627 'id' => 'network-admin-t',
628 'title' => __( 'Themes' ),
629 'href' => network_admin_url( 'themes.php' ),
630 )
631 );
632 }
633
634 if ( current_user_can( 'manage_network_plugins' ) ) {
635 $wp_admin_bar->add_node(
636 array(
637 'parent' => 'network-admin',
638 'id' => 'network-admin-p',
639 'title' => __( 'Plugins' ),
640 'href' => network_admin_url( 'plugins.php' ),
641 )
642 );
643 }
644
645 if ( current_user_can( 'manage_network_options' ) ) {
646 $wp_admin_bar->add_node(
647 array(
648 'parent' => 'network-admin',
649 'id' => 'network-admin-o',
650 'title' => __( 'Settings' ),
651 'href' => network_admin_url( 'settings.php' ),
652 )
653 );
654 }
655 }
656
657 // Add site links.
658 $wp_admin_bar->add_group(
659 array(
660 'parent' => 'my-sites',
661 'id' => 'my-sites-list',
662 'meta' => array(
663 'class' => current_user_can( 'manage_network' ) ? 'ab-sub-secondary' : '',
664 ),
665 )
666 );
667
668 /**
669 * Filters whether to show the site icons in toolbar.
670 *
671 * Returning false to this hook is the recommended way to hide site icons in the toolbar.
672 * A truthy return may have negative performance impact on large multisites.
673 *
674 * @since 6.0.0
675 *
676 * @param bool $show_site_icons Whether site icons should be shown in the toolbar. Default true.
677 */
678 $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
679
680 foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
681 switch_to_blog( $blog->userblog_id );
682
683 if ( true === $show_site_icons && has_site_icon() ) {
684 $blavatar = sprintf(
685 '<img class="blavatar" src="%s" srcset="%s 2x" alt="" width="16" height="16"%s />',
686 esc_url( get_site_icon_url( 16 ) ),
687 esc_url( get_site_icon_url( 32 ) ),
688 ( wp_lazy_loading_enabled( 'img', 'site_icon_in_toolbar' ) ? ' loading="lazy"' : '' )
689 );
690 } else {
691 $blavatar = '<div class="blavatar"></div>';
692 }
693
694 $blogname = $blog->blogname;
695
696 if ( ! $blogname ) {
697 $blogname = preg_replace( '#^(https?://)?(www\.)?#', '', get_home_url() );
698 }
699
700 $menu_id = 'blog-' . $blog->userblog_id;
701
702 if ( current_user_can( 'read' ) ) {
703 $wp_admin_bar->add_node(
704 array(
705 'parent' => 'my-sites-list',
706 'id' => $menu_id,
707 'title' => $blavatar . $blogname,
708 'href' => admin_url(),
709 )
710 );
711
712 $wp_admin_bar->add_node(
713 array(
714 'parent' => $menu_id,
715 'id' => $menu_id . '-d',
716 'title' => __( 'Dashboard' ),
717 'href' => admin_url(),
718 )
719 );
720 } else {
721 $wp_admin_bar->add_node(
722 array(
723 'parent' => 'my-sites-list',
724 'id' => $menu_id,
725 'title' => $blavatar . $blogname,
726 'href' => home_url(),
727 )
728 );
729 }
730
731 if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
732 $wp_admin_bar->add_node(
733 array(
734 'parent' => $menu_id,
735 'id' => $menu_id . '-n',
736 'title' => get_post_type_object( 'post' )->labels->new_item,
737 'href' => admin_url( 'post-new.php' ),
738 )
739 );
740 }
741
742 if ( current_user_can( 'edit_posts' ) ) {
743 $wp_admin_bar->add_node(
744 array(
745 'parent' => $menu_id,
746 'id' => $menu_id . '-c',
747 'title' => __( 'Manage Comments' ),
748 'href' => admin_url( 'edit-comments.php' ),
749 )
750 );
751 }
752
753 $wp_admin_bar->add_node(
754 array(
755 'parent' => $menu_id,
756 'id' => $menu_id . '-v',
757 'title' => __( 'Visit Site' ),
758 'href' => home_url( '/' ),
759 )
760 );
761
762 restore_current_blog();
763 }
764}
765
766/**
767 * Provides a shortlink.
768 *
769 * @since 3.1.0
770 *
771 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
772 */
773function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
774 $short = wp_get_shortlink( 0, 'query' );
775 $id = 'get-shortlink';
776
777 if ( empty( $short ) ) {
778 return;
779 }
780
781 $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" aria-label="' . __( 'Shortlink' ) . '" />';
782
783 $wp_admin_bar->add_node(
784 array(
785 'id' => $id,
786 'title' => __( 'Shortlink' ),
787 'href' => $short,
788 'meta' => array( 'html' => $html ),
789 )
790 );
791}
792
793/**
794 * Provides an edit link for posts and terms.
795 *
796 * @since 3.1.0
797 * @since 5.5.0 Added a "View Post" link on Comments screen for a single post.
798 *
799 * @global WP_Term $tag
800 * @global WP_Query $wp_the_query WordPress Query object.
801 * @global int $user_id The ID of the user being edited. Not to be confused with the
802 * global $user_ID, which contains the ID of the current user.
803 * @global int $post_id The ID of the post when editing comments for a single post.
804 *
805 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
806 */
807function wp_admin_bar_edit_menu( $wp_admin_bar ) {
808 global $tag, $wp_the_query, $user_id, $post_id;
809
810 if ( is_admin() ) {
811 $current_screen = get_current_screen();
812 $post = get_post();
813 $post_type_object = null;
814
815 if ( 'post' === $current_screen->base ) {
816 $post_type_object = get_post_type_object( $post->post_type );
817 } elseif ( 'edit' === $current_screen->base ) {
818 $post_type_object = get_post_type_object( $current_screen->post_type );
819 } elseif ( 'edit-comments' === $current_screen->base && $post_id ) {
820 $post = get_post( $post_id );
821 if ( $post ) {
822 $post_type_object = get_post_type_object( $post->post_type );
823 }
824 }
825
826 if ( ( 'post' === $current_screen->base || 'edit-comments' === $current_screen->base )
827 && 'add' !== $current_screen->action
828 && ( $post_type_object )
829 && current_user_can( 'read_post', $post->ID )
830 && ( $post_type_object->public )
831 && ( $post_type_object->show_in_admin_bar ) ) {
832 if ( 'draft' === $post->post_status ) {
833 $preview_link = get_preview_post_link( $post );
834 $wp_admin_bar->add_node(
835 array(
836 'id' => 'preview',
837 'title' => $post_type_object->labels->view_item,
838 'href' => esc_url( $preview_link ),
839 'meta' => array( 'target' => 'wp-preview-' . $post->ID ),
840 )
841 );
842 } else {
843 $wp_admin_bar->add_node(
844 array(
845 'id' => 'view',
846 'title' => $post_type_object->labels->view_item,
847 'href' => get_permalink( $post->ID ),
848 )
849 );
850 }
851 } elseif ( 'edit' === $current_screen->base
852 && ( $post_type_object )
853 && ( $post_type_object->public )
854 && ( $post_type_object->show_in_admin_bar )
855 && ( get_post_type_archive_link( $post_type_object->name ) )
856 && ! ( 'post' === $post_type_object->name && 'posts' === get_option( 'show_on_front' ) ) ) {
857 $wp_admin_bar->add_node(
858 array(
859 'id' => 'archive',
860 'title' => $post_type_object->labels->view_items,
861 'href' => get_post_type_archive_link( $current_screen->post_type ),
862 )
863 );
864 } elseif ( 'term' === $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
865 $tax = get_taxonomy( $tag->taxonomy );
866 if ( is_term_publicly_viewable( $tag ) ) {
867 $wp_admin_bar->add_node(
868 array(
869 'id' => 'view',
870 'title' => $tax->labels->view_item,
871 'href' => get_term_link( $tag ),
872 )
873 );
874 }
875 } elseif ( 'user-edit' === $current_screen->base && isset( $user_id ) ) {
876 $user_object = get_userdata( $user_id );
877 $view_link = get_author_posts_url( $user_object->ID );
878 if ( $user_object->exists() && $view_link ) {
879 $wp_admin_bar->add_node(
880 array(
881 'id' => 'view',
882 'title' => __( 'View User' ),
883 'href' => $view_link,
884 )
885 );
886 }
887 }
888 } else {
889 $current_object = $wp_the_query->get_queried_object();
890
891 if ( empty( $current_object ) ) {
892 return;
893 }
894
895 if ( ! empty( $current_object->post_type ) ) {
896 $post_type_object = get_post_type_object( $current_object->post_type );
897 $edit_post_link = get_edit_post_link( $current_object->ID );
898 if ( $post_type_object
899 && $edit_post_link
900 && current_user_can( 'edit_post', $current_object->ID )
901 && $post_type_object->show_in_admin_bar ) {
902 $wp_admin_bar->add_node(
903 array(
904 'id' => 'edit',
905 'title' => $post_type_object->labels->edit_item,
906 'href' => $edit_post_link,
907 )
908 );
909 }
910 } elseif ( ! empty( $current_object->taxonomy ) ) {
911 $tax = get_taxonomy( $current_object->taxonomy );
912 $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy );
913 if ( $tax && $edit_term_link && current_user_can( 'edit_term', $current_object->term_id ) ) {
914 $wp_admin_bar->add_node(
915 array(
916 'id' => 'edit',
917 'title' => $tax->labels->edit_item,
918 'href' => $edit_term_link,
919 )
920 );
921 }
922 } elseif ( $current_object instanceof WP_User && current_user_can( 'edit_user', $current_object->ID ) ) {
923 $edit_user_link = get_edit_user_link( $current_object->ID );
924 if ( $edit_user_link ) {
925 $wp_admin_bar->add_node(
926 array(
927 'id' => 'edit',
928 'title' => __( 'Edit User' ),
929 'href' => $edit_user_link,
930 )
931 );
932 }
933 }
934 }
935}
936
937/**
938 * Adds "Add New" menu.
939 *
940 * @since 3.1.0
941 * @since 6.5.0 Added a New Site link for network installations.
942 *
943 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
944 */
945function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
946 $actions = array();
947
948 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
949
950 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) {
951 $actions['post-new.php'] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
952 }
953
954 if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) {
955 $actions['media-new.php'] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
956 }
957
958 if ( current_user_can( 'manage_links' ) ) {
959 $actions['link-add.php'] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
960 }
961
962 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) {
963 $actions['post-new.php?post_type=page'] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
964 }
965
966 unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
967
968 // Add any additional custom post types.
969 foreach ( $cpts as $cpt ) {
970 if ( ! current_user_can( $cpt->cap->create_posts ) ) {
971 continue;
972 }
973
974 $key = 'post-new.php?post_type=' . $cpt->name;
975 $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
976 }
977 // Avoid clash with parent node and a 'content' post type.
978 if ( isset( $actions['post-new.php?post_type=content'] ) ) {
979 $actions['post-new.php?post_type=content'][1] = 'add-new-content';
980 }
981
982 if ( current_user_can( 'create_users' ) || ( is_multisite() && current_user_can( 'promote_users' ) ) ) {
983 $actions['user-new.php'] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
984 }
985
986 if ( ! $actions ) {
987 return;
988 }
989
990 $title = '<span class="ab-icon" aria-hidden="true"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
991
992 $wp_admin_bar->add_node(
993 array(
994 'id' => 'new-content',
995 'title' => $title,
996 'href' => admin_url( current( array_keys( $actions ) ) ),
997 'meta' => array(
998 'menu_title' => _x( 'New', 'admin bar menu group label' ),
999 ),
1000 )
1001 );
1002
1003 foreach ( $actions as $link => $action ) {
1004 list( $title, $id ) = $action;
1005
1006 $wp_admin_bar->add_node(
1007 array(
1008 'parent' => 'new-content',
1009 'id' => $id,
1010 'title' => $title,
1011 'href' => admin_url( $link ),
1012 )
1013 );
1014 }
1015
1016 if ( is_multisite() && current_user_can( 'create_sites' ) ) {
1017 $wp_admin_bar->add_node(
1018 array(
1019 'parent' => 'new-content',
1020 'id' => 'add-new-site',
1021 'title' => _x( 'Site', 'add new from admin bar' ),
1022 'href' => network_admin_url( 'site-new.php' ),
1023 )
1024 );
1025 }
1026}
1027
1028/**
1029 * Adds edit comments link with awaiting moderation count bubble.
1030 *
1031 * @since 3.1.0
1032 *
1033 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1034 */
1035function wp_admin_bar_comments_menu( $wp_admin_bar ) {
1036 if ( ! current_user_can( 'edit_posts' ) ) {
1037 return;
1038 }
1039
1040 $awaiting_mod = wp_count_comments();
1041 $awaiting_mod = $awaiting_mod->moderated;
1042 $awaiting_text = sprintf(
1043 /* translators: Hidden accessibility text. %s: Number of comments. */
1044 _n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
1045 number_format_i18n( $awaiting_mod )
1046 );
1047
1048 $icon = '<span class="ab-icon" aria-hidden="true"></span>';
1049 $title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
1050 $title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
1051
1052 $wp_admin_bar->add_node(
1053 array(
1054 'id' => 'comments',
1055 'title' => $icon . $title,
1056 'href' => admin_url( 'edit-comments.php' ),
1057 )
1058 );
1059}
1060
1061/**
1062 * Adds appearance submenu items to the "Site Name" menu.
1063 *
1064 * @since 3.1.0
1065 *
1066 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1067 */
1068function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
1069 $wp_admin_bar->add_group(
1070 array(
1071 'parent' => 'site-name',
1072 'id' => 'appearance',
1073 )
1074 );
1075
1076 if ( current_user_can( 'switch_themes' ) ) {
1077 $wp_admin_bar->add_node(
1078 array(
1079 'parent' => 'appearance',
1080 'id' => 'themes',
1081 'title' => __( 'Themes' ),
1082 'href' => admin_url( 'themes.php' ),
1083 )
1084 );
1085 }
1086
1087 if ( ! current_user_can( 'edit_theme_options' ) ) {
1088 return;
1089 }
1090
1091 if ( current_theme_supports( 'widgets' ) ) {
1092 $wp_admin_bar->add_node(
1093 array(
1094 'parent' => 'appearance',
1095 'id' => 'widgets',
1096 'title' => __( 'Widgets' ),
1097 'href' => admin_url( 'widgets.php' ),
1098 )
1099 );
1100 }
1101
1102 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
1103 $wp_admin_bar->add_node(
1104 array(
1105 'parent' => 'appearance',
1106 'id' => 'menus',
1107 'title' => __( 'Menus' ),
1108 'href' => admin_url( 'nav-menus.php' ),
1109 )
1110 );
1111 }
1112
1113 if ( current_theme_supports( 'custom-background' ) ) {
1114 $wp_admin_bar->add_node(
1115 array(
1116 'parent' => 'appearance',
1117 'id' => 'background',
1118 'title' => _x( 'Background', 'custom background' ),
1119 'href' => admin_url( 'themes.php?page=custom-background' ),
1120 'meta' => array(
1121 'class' => 'hide-if-customize',
1122 ),
1123 )
1124 );
1125 }
1126
1127 if ( current_theme_supports( 'custom-header' ) ) {
1128 $wp_admin_bar->add_node(
1129 array(
1130 'parent' => 'appearance',
1131 'id' => 'header',
1132 'title' => _x( 'Header', 'custom image header' ),
1133 'href' => admin_url( 'themes.php?page=custom-header' ),
1134 'meta' => array(
1135 'class' => 'hide-if-customize',
1136 ),
1137 )
1138 );
1139 }
1140}
1141
1142/**
1143 * Provides an update link if theme/plugin/core updates are available.
1144 *
1145 * @since 3.1.0
1146 *
1147 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1148 */
1149function wp_admin_bar_updates_menu( $wp_admin_bar ) {
1150
1151 $update_data = wp_get_update_data();
1152
1153 if ( ! $update_data['counts']['total'] ) {
1154 return;
1155 }
1156
1157 $updates_text = sprintf(
1158 /* translators: Hidden accessibility text. %s: Total number of updates available. */
1159 _n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
1160 number_format_i18n( $update_data['counts']['total'] )
1161 );
1162
1163 $icon = '<span class="ab-icon" aria-hidden="true"></span>';
1164 $title = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
1165 $title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';
1166
1167 $wp_admin_bar->add_node(
1168 array(
1169 'id' => 'updates',
1170 'title' => $icon . $title,
1171 'href' => network_admin_url( 'update-core.php' ),
1172 )
1173 );
1174}
1175
1176/**
1177 * Adds search form.
1178 *
1179 * @since 3.3.0
1180 *
1181 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1182 */
1183function wp_admin_bar_search_menu( $wp_admin_bar ) {
1184 if ( is_admin() ) {
1185 return;
1186 }
1187
1188 $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
1189 $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
1190 $form .= '<label for="adminbar-search" class="screen-reader-text">' .
1191 /* translators: Hidden accessibility text. */
1192 __( 'Search' ) .
1193 '</label>';
1194 $form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '" />';
1195 $form .= '</form>';
1196
1197 $wp_admin_bar->add_node(
1198 array(
1199 'parent' => 'top-secondary',
1200 'id' => 'search',
1201 'title' => $form,
1202 'meta' => array(
1203 'class' => 'admin-bar-search',
1204 'tabindex' => -1,
1205 ),
1206 )
1207 );
1208}
1209
1210/**
1211 * Adds a link to exit recovery mode when Recovery Mode is active.
1212 *
1213 * @since 5.2.0
1214 *
1215 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1216 */
1217function wp_admin_bar_recovery_mode_menu( $wp_admin_bar ) {
1218 if ( ! wp_is_recovery_mode() ) {
1219 return;
1220 }
1221
1222 $url = wp_login_url();
1223 $url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url );
1224 $url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
1225
1226 $wp_admin_bar->add_node(
1227 array(
1228 'parent' => 'top-secondary',
1229 'id' => 'recovery-mode',
1230 'title' => __( 'Exit Recovery Mode' ),
1231 'href' => $url,
1232 )
1233 );
1234}
1235
1236/**
1237 * Adds secondary menus.
1238 *
1239 * @since 3.3.0
1240 *
1241 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
1242 */
1243function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) {
1244 $wp_admin_bar->add_group(
1245 array(
1246 'id' => 'top-secondary',
1247 'meta' => array(
1248 'class' => 'ab-top-secondary',
1249 ),
1250 )
1251 );
1252
1253 $wp_admin_bar->add_group(
1254 array(
1255 'parent' => 'wp-logo',
1256 'id' => 'wp-logo-external',
1257 'meta' => array(
1258 'class' => 'ab-sub-secondary',
1259 ),
1260 )
1261 );
1262}
1263
1264/**
1265 * Enqueues inline style to hide the admin bar when printing.
1266 *
1267 * @since 6.4.0
1268 */
1269function wp_enqueue_admin_bar_header_styles() {
1270 // Back-compat for plugins that disable functionality by unhooking this action.
1271 $action = is_admin() ? 'admin_head' : 'wp_head';
1272 if ( ! has_action( $action, 'wp_admin_bar_header' ) ) {
1273 return;
1274 }
1275 remove_action( $action, 'wp_admin_bar_header' );
1276
1277 wp_add_inline_style( 'admin-bar', '@media print { #wpadminbar { display:none; } }' );
1278}
1279
1280/**
1281 * Enqueues inline bump styles to make room for the admin bar.
1282 *
1283 * @since 6.4.0
1284 */
1285function wp_enqueue_admin_bar_bump_styles() {
1286 if ( current_theme_supports( 'admin-bar' ) ) {
1287 $admin_bar_args = get_theme_support( 'admin-bar' );
1288 $header_callback = $admin_bar_args[0]['callback'];
1289 }
1290
1291 if ( empty( $header_callback ) ) {
1292 $header_callback = '_admin_bar_bump_cb';
1293 }
1294
1295 if ( '_admin_bar_bump_cb' !== $header_callback ) {
1296 return;
1297 }
1298
1299 // Back-compat for plugins that disable functionality by unhooking this action.
1300 if ( ! has_action( 'wp_head', $header_callback ) ) {
1301 return;
1302 }
1303 remove_action( 'wp_head', $header_callback );
1304
1305 $css = '
1306 @media screen { html { margin-top: 32px !important; } }
1307 @media screen and ( max-width: 782px ) { html { margin-top: 46px !important; } }
1308 ';
1309 wp_add_inline_style( 'admin-bar', $css );
1310}
1311
1312/**
1313 * Sets the display status of the admin bar.
1314 *
1315 * This can be called immediately upon plugin load. It does not need to be called
1316 * from a function hooked to the {@see 'init'} action.
1317 *
1318 * @since 3.1.0
1319 *
1320 * @global bool $show_admin_bar
1321 *
1322 * @param bool $show Whether to allow the admin bar to show.
1323 */
1324function show_admin_bar( $show ) {
1325 global $show_admin_bar;
1326 $show_admin_bar = (bool) $show;
1327}
1328
1329/**
1330 * Determines whether the admin bar should be showing.
1331 *
1332 * For more information on this and similar theme functions, check out
1333 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
1334 * Conditional Tags} article in the Theme Developer Handbook.
1335 *
1336 * @since 3.1.0
1337 *
1338 * @global bool $show_admin_bar
1339 * @global string $pagenow The filename of the current screen.
1340 *
1341 * @return bool Whether the admin bar should be showing.
1342 */
1343function is_admin_bar_showing() {
1344 global $show_admin_bar, $pagenow;
1345
1346 // For all these types of requests, we never want an admin bar.
1347 if ( defined( 'XMLRPC_REQUEST' ) || defined( 'DOING_AJAX' ) || defined( 'IFRAME_REQUEST' ) || wp_is_json_request() ) {
1348 return false;
1349 }
1350
1351 if ( is_embed() ) {
1352 return false;
1353 }
1354
1355 // Integrated into the admin.
1356 if ( is_admin() ) {
1357 return true;
1358 }
1359
1360 if ( ! isset( $show_admin_bar ) ) {
1361 if ( ! is_user_logged_in() || 'wp-login.php' === $pagenow ) {
1362 $show_admin_bar = false;
1363 } else {
1364 $show_admin_bar = _get_admin_bar_pref();
1365 }
1366 }
1367
1368 /**
1369 * Filters whether to show the admin bar.
1370 *
1371 * Returning false to this hook is the recommended way to hide the admin bar.
1372 * The user's display preference is used for logged in users.
1373 *
1374 * @since 3.1.0
1375 *
1376 * @param bool $show_admin_bar Whether the admin bar should be shown. Default false.
1377 */
1378 $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );
1379
1380 return $show_admin_bar;
1381}
1382
1383/**
1384 * Retrieves the admin bar display preference of a user.
1385 *
1386 * @since 3.1.0
1387 * @access private
1388 *
1389 * @param string $context Context of this preference check. Defaults to 'front'. The 'admin'
1390 * preference is no longer used.
1391 * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
1392 * @return bool Whether the admin bar should be showing for this user.
1393 */
1394function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
1395 $pref = get_user_option( "show_admin_bar_{$context}", $user );
1396 if ( false === $pref ) {
1397 return true;
1398 }
1399
1400 return 'true' === $pref;
1401}
1402
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.