@@ -43,6 +43,16 @@ function filter_admin_bar_links( $wp_admin_bar ) {
43
43
[ 'updates ' , 'stats ' , 'search ' , 'my-sites ' , 'admin-bar-likes-widget ' ]
44
44
);
45
45
46
+ // Restore edit profile link.
47
+ $ wp_admin_bar ->add_node (
48
+ array (
49
+ 'parent ' => 'my-account-actions ' ,
50
+ 'id ' => 'edit-profile ' ,
51
+ 'title ' => __ ( 'Edit Profile ' ),
52
+ 'href ' => get_edit_profile_url ( get_current_user_id () ),
53
+ )
54
+ );
55
+
46
56
// Empty array so we can reverse it to keep the correct order.
47
57
$ edit_items = [];
48
58
@@ -58,9 +68,20 @@ function filter_admin_bar_links( $wp_admin_bar ) {
58
68
$ ab_item ->meta ['class ' ] = 'ab-sub-secondary ' ;
59
69
}
60
70
$ wp_admin_bar ->add_node ( $ ab_item );
61
- } else if ( in_array ( $ ab_item ->id , [ 'edit-profile ' , 'logout ' ] ) ) {
62
- // Move "Edit Profile" and "Logout" to a new group at the end of the dropdown.
71
+ } else if ( 'user-info ' === $ ab_item ->id || 'my-account ' === $ ab_item ->id ) {
72
+ // Change the link location to the profile, rather than edit.
73
+ $ ab_item ->href = str_replace ( '/profile/edit/ ' , '/ ' , $ ab_item ->href );
74
+
75
+ // Remove the Edit Profile text.
76
+ $ ab_item ->title = preg_replace ( '!<span[^>]+edit-profile[^>]+>[^<]+</span>!i ' , '' , $ ab_item ->title );
77
+
78
+ $ wp_admin_bar ->add_node ( $ ab_item );
79
+ } else if ( 'logout ' === $ ab_item ->id ) {
80
+ // Move "Logout" to a new group at the end of the dropdown.
63
81
$ ab_item ->parent = 'my-account-actions ' ;
82
+
83
+ // Remove it before adding, to ensure it's after the Edit Profile link.
84
+ $ wp_admin_bar ->remove_node ('logout ' );
64
85
$ wp_admin_bar ->add_node ( $ ab_item );
65
86
} else if ( in_array ( $ ab_item ->id , [ 'edit ' , 'site-editor ' , 'customize ' ] ) ) {
66
87
// Move "Edit [object]", "Customize", and "Edit Site" (if exist) to list to be
0 commit comments