按照以下步骤添加注销和编辑我的个人资料之间的链接
1。删除默认注销节点
$wp_admin_bar->remove_node( \'logout\' );
2。添加要在注销和编辑我的个人资料之间放置的链接
$wp_admin_bar->add_node([
\'id\' => \'link-id\',
\'title\' => \'Link Title\',
\'href\' => get_site_url(null, \'site-path\'),
\'parent\' => \'user-actions\'
]);
3。使用以下命令将注销节点添加回列表:
$wp_admin_bar->add_node([
\'id\' => \'logout\',
\'title\' => \'Log Out\',
\'href\' => wp_logout_url(),
\'parent\' => \'user-actions\'
]);
只是操纵了上述函数,以便在注销和配置文件之间插入链接。
最终代码:
add_action( \'admin_bar_menu\', \'adjust_admin_menu_bar_items\' , 999);
function adjust_admin_menu_bar_items ($wp_admin_bar) {
$user = wp_get_current_user();
$wp_admin_bar->add_node([
\'id\' => \'link-id\',
\'title\' => \'Link Title\',
\'href\' => get_site_url(null, \'site-path\'),
\'parent\' => \'user-actions\'
]);
$wp_admin_bar->add_node([
\'id\' => \'logout\',
\'title\' => \'Log Out\',
\'href\' => wp_logout_url(),
\'parent\' => \'user-actions\'
]);
}
希望这会有所帮助。:)