31 return array(); // Sorry, folks. |
33 return array(); // Sorry, folks. |
32 } |
34 } |
33 } |
35 } |
34 |
36 |
35 /** |
37 /** |
|
38 * Initializes the admin bar. |
|
39 * |
|
40 * @since 3.1.0 |
36 */ |
41 */ |
37 public function initialize() { |
42 public function initialize() { |
38 $this->user = new stdClass; |
43 $this->user = new stdClass; |
39 |
44 |
40 if ( is_user_logged_in() ) { |
45 if ( is_user_logged_in() ) { |
80 */ |
85 */ |
81 do_action( 'admin_bar_init' ); |
86 do_action( 'admin_bar_init' ); |
82 } |
87 } |
83 |
88 |
84 /** |
89 /** |
85 * Add a node (menu item) to the Admin Bar menu. |
90 * Adds a node (menu item) to the admin bar menu. |
86 * |
91 * |
87 * @since 3.3.0 |
92 * @since 3.3.0 |
88 * |
93 * |
89 * @param array $node The attributes that define the node. |
94 * @param array $node The attributes that define the node. |
90 */ |
95 */ |
91 public function add_menu( $node ) { |
96 public function add_menu( $node ) { |
92 $this->add_node( $node ); |
97 $this->add_node( $node ); |
93 } |
98 } |
94 |
99 |
95 /** |
100 /** |
96 * Remove a node from the admin bar. |
101 * Removes a node from the admin bar. |
97 * |
102 * |
98 * @since 3.1.0 |
103 * @since 3.1.0 |
99 * |
104 * |
100 * @param string $id The menu slug to remove. |
105 * @param string $id The menu slug to remove. |
101 */ |
106 */ |
177 |
182 |
178 $this->_set_node( $args ); |
183 $this->_set_node( $args ); |
179 } |
184 } |
180 |
185 |
181 /** |
186 /** |
|
187 * @since 3.3.0 |
|
188 * |
182 * @param array $args |
189 * @param array $args |
183 */ |
190 */ |
184 final protected function _set_node( $args ) { |
191 final protected function _set_node( $args ) { |
185 $this->nodes[ $args['id'] ] = (object) $args; |
192 $this->nodes[ $args['id'] ] = (object) $args; |
186 } |
193 } |
187 |
194 |
188 /** |
195 /** |
189 * Gets a node. |
196 * Gets a node. |
|
197 * |
|
198 * @since 3.3.0 |
190 * |
199 * |
191 * @param string $id |
200 * @param string $id |
192 * @return object|void Node. |
201 * @return object|void Node. |
193 */ |
202 */ |
194 final public function get_node( $id ) { |
203 final public function get_node( $id ) { |
265 } |
280 } |
266 |
281 |
267 /** |
282 /** |
268 * Remove a node. |
283 * Remove a node. |
269 * |
284 * |
|
285 * @since 3.1.0 |
|
286 * |
270 * @param string $id The ID of the item. |
287 * @param string $id The ID of the item. |
271 */ |
288 */ |
272 public function remove_node( $id ) { |
289 public function remove_node( $id ) { |
273 $this->_unset_node( $id ); |
290 $this->_unset_node( $id ); |
274 } |
291 } |
275 |
292 |
276 /** |
293 /** |
|
294 * @since 3.3.0 |
|
295 * |
277 * @param string $id |
296 * @param string $id |
278 */ |
297 */ |
279 final protected function _unset_node( $id ) { |
298 final protected function _unset_node( $id ) { |
280 unset( $this->nodes[ $id ] ); |
299 unset( $this->nodes[ $id ] ); |
281 } |
300 } |
282 |
301 |
283 /** |
302 /** |
|
303 * @since 3.1.0 |
284 */ |
304 */ |
285 public function render() { |
305 public function render() { |
286 $root = $this->_bind(); |
306 $root = $this->_bind(); |
287 if ( $root ) { |
307 if ( $root ) { |
288 $this->_render( $root ); |
308 $this->_render( $root ); |
289 } |
309 } |
290 } |
310 } |
291 |
311 |
292 /** |
312 /** |
|
313 * @since 3.3.0 |
|
314 * |
293 * @return object|void |
315 * @return object|void |
294 */ |
316 */ |
295 final protected function _bind() { |
317 final protected function _bind() { |
296 if ( $this->bound ) { |
318 if ( $this->bound ) { |
297 return; |
319 return; |
594 _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' ); |
624 _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' ); |
595 $this->_render_item( $node ); |
625 $this->_render_item( $node ); |
596 } |
626 } |
597 |
627 |
598 /** |
628 /** |
|
629 * Adds menus to the admin bar. |
|
630 * |
|
631 * @since 3.1.0 |
599 */ |
632 */ |
600 public function add_menus() { |
633 public function add_menus() { |
601 // User-related, aligned right. |
634 // User-related, aligned right. |
602 add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); |
635 add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); |
603 add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); |
636 add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); |
607 // Site-related. |
640 // Site-related. |
608 add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); |
641 add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); |
609 add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); |
642 add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); |
610 add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); |
643 add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); |
611 add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 ); |
644 add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 ); |
|
645 add_action( 'admin_bar_menu', 'wp_admin_bar_edit_site_menu', 40 ); |
612 add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 ); |
646 add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 ); |
613 add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 ); |
647 add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 ); |
614 |
648 |
615 // Content-related. |
649 // Content-related. |
616 if ( ! is_network_admin() && ! is_user_admin() ) { |
650 if ( ! is_network_admin() && ! is_user_admin() ) { |