Skip to content

Commit c5a5c20

Browse files
Docs: Add changing existing items recommendations to 'admin_bar_menu' action.
Improves the `'admin_bar_menu'` docblock by adding recommendations for customizing / changing existing items. It also improves the `wp_admin_bar_render()` function's docblock by removing the "most optimal point" sentence. The [58748] changeset moved the user menu to a higher priority level (of `9991`) to achieve: >so nodes added with higher priorities will still be shown visually before the user and recovery menu items, as they were prior to [58215]. When hooking into `'admin_bar_menu'` with a priority level less than 9991 and attempting to get the `'my-account'` node, `null` is returned. While the preferred approach is to hook into `'wp_before_admin_bar_render'`, the documentation of the `'admin_bar_menu'` action was previously misleading. Follow-up to [58748], [58759]. Props michaelwp85, narenin, sabernhardt, joedolson, costdev, jorbin, hellofromTonya, mukesh27, pbiron. Fixes #61738. git-svn-id: https://develop.svn.wordpress.org/trunk@58978 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 79c1047 commit c5a5c20

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/wp-includes/admin-bar.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ function _wp_admin_bar_init() {
6262
* the function is also called late on {@see 'wp_footer'}.
6363
*
6464
* It includes the {@see 'admin_bar_menu'} action which should be used to hook in and
65-
* add new menus to the admin bar. That way you can be sure that you are adding at most
66-
* optimal point, right before the admin bar is rendered. This also gives you access to
67-
* the `$post` global, among others.
65+
* add new menus to the admin bar. This also gives you access to the `$post` global,
66+
* among others.
6867
*
6968
* @since 3.1.0
7069
* @since 5.4.0 Called on 'wp_body_open' action first, with 'wp_footer' as a fallback.
@@ -86,7 +85,10 @@ function wp_admin_bar_render() {
8685
/**
8786
* Loads all necessary admin bar items.
8887
*
89-
* This is the hook used to add, remove, or manipulate admin bar items.
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`.
9092
*
9193
* @since 3.1.0
9294
*

0 commit comments

Comments
 (0)