Skip to content

Commit

Permalink
Point Howdy to /me
Browse files Browse the repository at this point in the history
  • Loading branch information
okmttdhr committed Aug 29, 2024
1 parent 6e789ba commit 4bca551
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ public function add_node( $args ) {
parent::add_node( $args );
return;
}

if ( $args['id'] === 'my-account' ) {
if ( ! is_user_member_of_blog() || get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
$args['href'] = 'https://wordpress.com/me';

// Temporarily point to wpcalypso.wordpress.com for testing purposes.
if ( get_option( 'wpcom_site_level_user_profile' ) === '1' ) {
$args['href'] = 'https://wpcalypso.wordpress.com/me';
}
}
}

$home_url = home_url( '/' );
$site_slug = wp_parse_url( $home_url, PHP_URL_HOST );
$href = str_replace( $home_url, '', $args['href'] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,22 @@ function wpcom_add_reader_menu( $wp_admin_bar ) {
add_action( 'admin_bar_menu', 'wpcom_add_reader_menu', 11 );

/**
* Points the (Profile) -> Edit Profile menu to /me when appropriate.
* Points the "Edit Profile" and "Howdy,..." to /me when appropriate.
*
* @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 ) {
/**
* The Edit Profile menu should point to /me, instead of the site's profile.php
* if one of the following is true:
* - the user is not a member of the current site
* - the current site uses Default admin interface AND the site-level user profile is disabled
*/
$should_replace = ! is_user_member_of_blog() || ( empty( get_option( 'wpcom_site_level_user_profile' ) ) && get_option( 'wpcom_admin_interface' ) !== 'wp-admin' );

$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 one of the following is true:
* - the user is not a member of the current site
* - the current site uses Default admin interface AND the site-level user profile is disabled
*/
if ( ! is_user_member_of_blog() || ( empty( get_option( 'wpcom_site_level_user_profile' ) ) && get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) ) {

if ( $should_replace ) {
// Temporarily point to wpcalypso.wordpress.com for testing purposes.
$url = 'https://wordpress.com/me';
if ( ! empty( get_option( 'wpcom_site_level_user_profile' ) ) ) {
Expand All @@ -186,8 +187,22 @@ function wpcom_maybe_replace_edit_profile_menu_to_me( $wp_admin_bar ) {
$wp_admin_bar->add_node( (array) $edit_profile_node );
}
}

$my_account_node = $wp_admin_bar->get_node( 'my-account' );
if ( $my_account_node ) {
if ( $should_replace ) {
// Temporarily point to wpcalypso.wordpress.com for testing purposes.
$url = 'https://wordpress.com/me/account';
if ( ! empty( get_option( 'wpcom_site_level_user_profile' ) ) ) {
$url = 'https://wpcalypso.wordpress.com/me/account';
}

$my_account_node->href = maybe_add_origin_site_id_to_url( $url );
$wp_admin_bar->add_node( (array) $my_account_node );
}
}
}
add_action( 'admin_bar_menu', 'wpcom_maybe_replace_edit_profile_menu_to_me', 1 );
add_action( 'admin_bar_menu', 'wpcom_maybe_replace_edit_profile_menu_to_me', 9999 );

/**
* Adds (Profile) -> My Account menu pointing to /me/account.
Expand Down

0 comments on commit 4bca551

Please sign in to comment.