diff --git a/projects/packages/jetpack-mu-wpcom/changelog/edit-profile-link b/projects/packages/jetpack-mu-wpcom/changelog/edit-profile-link new file mode 100644 index 0000000000000..8de81cd40f31f --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/edit-profile-link @@ -0,0 +1,4 @@ +Significance: minor +Type: changed + +Admin bar: replace 'Edit Profile' and 'My Account' with 'My Profile' diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.php index 7109d817c4c3f..6bd50652ab522 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/wpcom-admin-bar.php @@ -236,52 +236,25 @@ function wpcom_add_reader_menu( $wp_admin_bar ) { add_action( 'admin_bar_menu', 'wpcom_add_reader_menu', 11 ); /** - * Points the "Edit Profile" and "Howdy,..." to /me when appropriate. + * Points the "Edit Profile" and "Howdy,..." to /me. * * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar core object. */ -function wpcom_maybe_replace_edit_profile_menu_to_me( $wp_admin_bar ) { +function wpcom_replace_edit_profile_menu_to_me( $wp_admin_bar ) { $edit_profile_node = $wp_admin_bar->get_node( 'user-info' ); if ( $edit_profile_node ) { - /** - * The Edit Profile menu should point to /me, instead of the site's profile.php - * if the user is not a member of the current site - */ - if ( ! is_user_member_of_blog() ) { - $edit_profile_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' ); - $wp_admin_bar->add_node( (array) $edit_profile_node ); - } - } -} -// Run this function later than Core: https://github.com/WordPress/wordpress-develop/blob/5a30482419f1b0bcc713a7fdee3a14afd67a1bca/src/wp-includes/class-wp-admin-bar.php#L651 -add_action( 'admin_bar_menu', 'wpcom_maybe_replace_edit_profile_menu_to_me', 9999 ); - -/** - * Adds (Profile) -> My Account menu pointing to /me. - * - * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar core object. - */ -function wpcom_add_my_account_item_to_profile_menu( $wp_admin_bar ) { - $logout_node = $wp_admin_bar->get_node( 'logout' ); - if ( $logout_node ) { - // Adds the 'My Account' menu item before 'Log Out'. - $wp_admin_bar->remove_node( 'logout' ); + $edit_profile_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' ); + $edit_profile_node->title = preg_replace( "/()(.*?)(<\/span>)/", '$1' . __( 'My Profile', 'jetpack-mu-wpcom' ) . '$3', $edit_profile_node->title ); + $wp_admin_bar->add_node( (array) $edit_profile_node ); } - - $wp_admin_bar->add_node( - array( - 'id' => 'wpcom-profile', - 'parent' => 'user-actions', - 'title' => __( 'My Account', 'jetpack-mu-wpcom' ), - 'href' => maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' ), - ) - ); - - if ( $logout_node ) { - $wp_admin_bar->add_node( (array) $logout_node ); + $my_account_node = $wp_admin_bar->get_node( 'my-account' ); + if ( $my_account_node ) { + $my_account_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' ); + $wp_admin_bar->add_node( (array) $my_account_node ); } } -add_action( 'admin_bar_menu', 'wpcom_add_my_account_item_to_profile_menu' ); +// Run this function later than Core: https://github.com/WordPress/wordpress-develop/blob/5a30482419f1b0bcc713a7fdee3a14afd67a1bca/src/wp-includes/class-wp-admin-bar.php#L651 +add_action( 'admin_bar_menu', 'wpcom_replace_edit_profile_menu_to_me', 9999 ); /** * Replaces the default admin bar class with our own.