Toolbar: Use `add_node()` instead of `add_menu()` in core.
This patch replaces all references to the add_menu() method with the add_node() one. (Also some code structure modifications for wp_admin_bar_appearance_menu().) Fixes: #19647 Props: linuxologos, paulschreiber, morganestes, akibjorklund, nacin, whyisjake. Built from https://develop.svn.wordpress.org/trunk@46642 git-svn-id: http://core.svn.wordpress.org/trunk@46442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
946217dcca
commit
5e7876622e
|
@ -131,11 +131,11 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
);
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu( $wp_logo_menu_args );
|
||||
$wp_admin_bar->add_node( $wp_logo_menu_args );
|
||||
|
||||
if ( $about_url ) {
|
||||
// Add "About WordPress" link
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'wp-logo',
|
||||
'id' => 'about',
|
||||
|
@ -146,7 +146,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
// Add WordPress.org link
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'wp-logo-external',
|
||||
'id' => 'wporg',
|
||||
|
@ -156,7 +156,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
// Add codex link
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'wp-logo-external',
|
||||
'id' => 'documentation',
|
||||
|
@ -166,7 +166,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
// Add forums link
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'wp-logo-external',
|
||||
'id' => 'support-forums',
|
||||
|
@ -176,7 +176,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
// Add feedback link
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'wp-logo-external',
|
||||
'id' => 'feedback',
|
||||
|
@ -195,7 +195,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
|||
*/
|
||||
function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
|
||||
if ( is_admin() ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'menu-toggle',
|
||||
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
|
||||
|
@ -233,7 +233,7 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
|
|||
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
|
||||
$class = empty( $avatar ) ? '' : 'with-avatar';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'my-account',
|
||||
'parent' => 'top-secondary',
|
||||
|
@ -283,7 +283,7 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
|||
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'user-info',
|
||||
|
@ -296,7 +296,7 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
if ( false !== $profile_url ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'edit-profile',
|
||||
|
@ -306,7 +306,7 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
|||
);
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'logout',
|
||||
|
@ -350,7 +350,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
|||
|
||||
$title = wp_html_excerpt( $blogname, 40, '…' );
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'site-name',
|
||||
'title' => $title,
|
||||
|
@ -362,7 +362,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
|||
|
||||
if ( is_admin() ) {
|
||||
// Add an option to visit the site.
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'site-name',
|
||||
'id' => 'view-site',
|
||||
|
@ -372,7 +372,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'site-name',
|
||||
'id' => 'edit-site',
|
||||
|
@ -383,7 +383,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
|||
}
|
||||
} elseif ( current_user_can( 'read' ) ) {
|
||||
// We're on the front end, link to the Dashboard.
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'site-name',
|
||||
'id' => 'dashboard',
|
||||
|
@ -428,7 +428,7 @@ function wp_admin_bar_customize_menu( $wp_admin_bar ) {
|
|||
$customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $customize_url );
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'customize',
|
||||
'title' => __( 'Customize' ),
|
||||
|
@ -465,7 +465,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
$my_sites_url = admin_url( 'my-sites.php' );
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'my-sites',
|
||||
'title' => __( 'My Sites' ),
|
||||
|
@ -481,7 +481,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
)
|
||||
);
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'my-sites-super-admin',
|
||||
'id' => 'network-admin',
|
||||
|
@ -490,7 +490,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
)
|
||||
);
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-d',
|
||||
|
@ -500,7 +500,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
if ( current_user_can( 'manage_sites' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-s',
|
||||
|
@ -511,7 +511,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( 'manage_network_users' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-u',
|
||||
|
@ -522,7 +522,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( 'manage_network_themes' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-t',
|
||||
|
@ -533,7 +533,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( 'manage_network_plugins' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-p',
|
||||
|
@ -544,7 +544,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( 'manage_network_options' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'network-admin',
|
||||
'id' => 'network-admin-o',
|
||||
|
@ -580,7 +580,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
$menu_id = 'blog-' . $blog->userblog_id;
|
||||
|
||||
if ( current_user_can( 'read' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'my-sites-list',
|
||||
'id' => $menu_id,
|
||||
|
@ -589,7 +589,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
)
|
||||
);
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-d',
|
||||
|
@ -598,7 +598,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
)
|
||||
);
|
||||
} else {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'my-sites-list',
|
||||
'id' => $menu_id,
|
||||
|
@ -609,7 +609,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-n',
|
||||
|
@ -620,7 +620,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-c',
|
||||
|
@ -630,7 +630,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
|
|||
);
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => $menu_id,
|
||||
'id' => $menu_id . '-v',
|
||||
|
@ -660,7 +660,7 @@ function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
|
|||
|
||||
$html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => $id,
|
||||
'title' => __( 'Shortlink' ),
|
||||
|
@ -702,7 +702,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
&& ( $post_type_object->show_in_admin_bar ) ) {
|
||||
if ( 'draft' == $post->post_status ) {
|
||||
$preview_link = get_preview_post_link( $post );
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'preview',
|
||||
'title' => $post_type_object->labels->view_item,
|
||||
|
@ -711,7 +711,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
)
|
||||
);
|
||||
} else {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => $post_type_object->labels->view_item,
|
||||
|
@ -735,7 +735,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
} elseif ( 'term' == $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
|
||||
$tax = get_taxonomy( $tag->taxonomy );
|
||||
if ( is_taxonomy_viewable( $tax ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => $tax->labels->view_item,
|
||||
|
@ -747,7 +747,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
$user_object = get_userdata( $user_id );
|
||||
$view_link = get_author_posts_url( $user_object->ID );
|
||||
if ( $user_object->exists() && $view_link ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => __( 'View User' ),
|
||||
|
@ -770,7 +770,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
&& $edit_post_link
|
||||
&& current_user_can( 'edit_post', $current_object->ID )
|
||||
&& $post_type_object->show_in_admin_bar ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $post_type_object->labels->edit_item,
|
||||
|
@ -782,7 +782,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
$tax = get_taxonomy( $current_object->taxonomy );
|
||||
$edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy );
|
||||
if ( $tax && $edit_term_link && current_user_can( 'edit_term', $current_object->term_id ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $tax->labels->edit_item,
|
||||
|
@ -793,7 +793,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
} elseif ( is_a( $current_object, 'WP_User' ) && current_user_can( 'edit_user', $current_object->ID ) ) {
|
||||
$edit_user_link = get_edit_user_link( $current_object->ID );
|
||||
if ( $edit_user_link ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => __( 'Edit User' ),
|
||||
|
@ -859,7 +859,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
|||
|
||||
$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'new-content',
|
||||
'title' => $title,
|
||||
|
@ -870,7 +870,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
|||
foreach ( $actions as $link => $action ) {
|
||||
list( $title, $id ) = $action;
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'new-content',
|
||||
'id' => $id,
|
||||
|
@ -905,7 +905,7 @@ function wp_admin_bar_comments_menu( $wp_admin_bar ) {
|
|||
$title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
|
||||
$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'comments',
|
||||
'title' => $icon . $title,
|
||||
|
@ -930,7 +930,7 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
|||
);
|
||||
|
||||
if ( current_user_can( 'switch_themes' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'themes',
|
||||
|
@ -945,7 +945,7 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_theme_supports( 'widgets' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'widgets',
|
||||
|
@ -956,7 +956,7 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'menus',
|
||||
|
@ -967,7 +967,7 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_theme_supports( 'custom-background' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'background',
|
||||
|
@ -981,7 +981,7 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
|||
}
|
||||
|
||||
if ( current_theme_supports( 'custom-header' ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'header',
|
||||
|
@ -1014,7 +1014,7 @@ function wp_admin_bar_updates_menu( $wp_admin_bar ) {
|
|||
$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
|
||||
$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'updates',
|
||||
'title' => $title,
|
||||
|
@ -1044,7 +1044,7 @@ function wp_admin_bar_search_menu( $wp_admin_bar ) {
|
|||
$form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '"/>';
|
||||
$form .= '</form>';
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'top-secondary',
|
||||
'id' => 'search',
|
||||
|
@ -1073,7 +1073,7 @@ function wp_admin_bar_recovery_mode_menu( $wp_admin_bar ) {
|
|||
$url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url );
|
||||
$url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'top-secondary',
|
||||
'id' => 'recovery-mode',
|
||||
|
|
|
@ -82,16 +82,28 @@ class WP_Admin_Bar {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $node
|
||||
* Add a node (menu item) to the Admin Bar menu.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @since 5.4.0 Deprecated in favor of {@see WP_Admin_Bar::add_node()}.
|
||||
*
|
||||
* @param array $node The attributes that define the node.
|
||||
*/
|
||||
public function add_menu( $node ) {
|
||||
_deprecated_function( __METHOD__, '5.4.0', __CLASS__ . '::add_node()' );
|
||||
$this->add_node( $node );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* Remove a node from the admin bar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 5.4.0 Deprecated in favor of {@see WP_Admin_Bar::remove_node()}.
|
||||
*
|
||||
* @param string $id The menu slug to remove.
|
||||
*/
|
||||
public function remove_menu( $id ) {
|
||||
_deprecated_function( __METHOD__, '5.4.0', __CLASS__ . '::remove_node()' );
|
||||
$this->remove_node( $id );
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.4-alpha-46641';
|
||||
$wp_version = '5.4-alpha-46642';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue