From f272c517566d9f54cb51104d4aead10d5d888548 Mon Sep 17 00:00:00 2001 From: Boone B Gorges Date: Mon, 18 Nov 2024 14:30:59 -0600 Subject: [PATCH] Use bp_members_get_user_url() instead of _user_domain() functions. See #458. --- includes/frontend-adminbar-bbpress.php | 8 ++++++-- includes/frontend-adminbar-bpdocs.php | 14 ++++++++++---- includes/frontend-adminbar-bpeo.php | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/includes/frontend-adminbar-bbpress.php b/includes/frontend-adminbar-bbpress.php index 9441b98d..10b7a19a 100644 --- a/includes/frontend-adminbar-bbpress.php +++ b/includes/frontend-adminbar-bbpress.php @@ -17,8 +17,12 @@ function cbox_frontend_adminbar_bbpress() { $my_engagements_link = $my_favorites_link = $my_subscriptions_link = ''; // Setup the logged in user variables - $user_domain = bp_loggedin_user_domain(); - $forums_link = trailingslashit( $user_domain . 'forums' ); + if ( function_exists( 'bp_members_get_user_url' ) ) { + $forums_link = bp_members_get_user_url( bp_loggedin_user_id(), bp_members_get_path_chunks( [ 'forums' ] ) ); + } else { + $user_domain = bp_loggedin_user_domain(); + $forums_link = trailingslashit( $user_domain . 'forums' ); + } // Engagements - only available in v2.6.0. if ( version_compare( $plugin_meta['Version'], '2.6') >= 0 && (bool) apply_filters( 'bbp_is_engagements_active', (bool) get_blog_option( cbox_get_main_site_id(), '_bbp_enable_engagements', 1 ) ) ) { diff --git a/includes/frontend-adminbar-bpdocs.php b/includes/frontend-adminbar-bpdocs.php index 6479b0e5..f09d077e 100644 --- a/includes/frontend-adminbar-bpdocs.php +++ b/includes/frontend-adminbar-bpdocs.php @@ -14,9 +14,15 @@ function cbox_frontend_adminbar_bpdocs() { $edited_slug = defined( 'BP_DOCS_EDITED_SLUG' ) ? BP_DOCS_EDITED_SLUG : 'edited'; $create_slug = defined( 'BP_DOCS_CREATE_SLUG' ) ? BP_DOCS_CREATE_SLUG : 'create'; - $docs_link = apply_filters( 'bp_docs_get_mydocs_link', trailingslashit( bp_loggedin_user_domain() . $slug ) ); - $started_link = apply_filters( 'bp_docs_get_mydocs_started_link', trailingslashit( $docs_link . $started_slug ) ); - $edited_link = apply_filters( 'bp_docs_get_mydocs_edited_link', trailingslashit( $docs_link . $edited_slug ) ); + $docs_link = bp_members_get_user_url( bp_loggedin_user_id(), bp_members_get_path_chunks( [ $slug ] ) ); + $docs_link = apply_filters( 'bp_docs_get_mydocs_link', $docs_link ); + + $started_link = bp_members_get_user_url( bp_loggedin_user_id(), bp_members_get_path_chunks( [ $slug, $started_slug ] ) ); + $started_link = apply_filters( 'bp_docs_get_mydocs_started_link', $started_link ); + + $edited_link = bp_members_get_user_url( bp_loggedin_user_id(), bp_members_get_path_chunks( [ $slug, $edited_slug ] ) ); + $edited_link = apply_filters( 'bp_docs_get_mydocs_edited_link', $edited_link ); + $archive_link = apply_filters( 'bp_docs_get_archive_link', trailingslashit( get_home_url( bp_get_root_blog_id(), $slug ) ) ); $create_link = apply_filters( 'bp_docs_get_create_link', trailingslashit( $archive_link . $create_slug ) ); @@ -55,4 +61,4 @@ function cbox_frontend_adminbar_bpdocs() { $GLOBALS['wp_admin_bar']->add_menu( $n ); } } -add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpdocs', 80 ); \ No newline at end of file +add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpdocs', 80 ); diff --git a/includes/frontend-adminbar-bpeo.php b/includes/frontend-adminbar-bpeo.php index fc24933b..1dea8669 100644 --- a/includes/frontend-adminbar-bpeo.php +++ b/includes/frontend-adminbar-bpeo.php @@ -6,7 +6,11 @@ function cbox_frontend_adminbar_bpeo() { $events_slug = defined( 'BPEO_EVENTS_SLUG' ) ? BPEO_EVENTS_SLUG : 'events'; $new_slug = defined( 'BPEO_EVENTS_NEW_SLUG' ) ? BPEO_EVENTS_NEW_SLUG : 'new-event'; - $link = trailingslashit( bp_loggedin_user_domain() . sanitize_title( $events_slug ) ); + if ( function_exists( 'bp_members_get_user_url' ) ) { + $link = bp_members_get_user_url( bp_loggedin_user_id(), bp_members_get_path_chunks( [ sanitize_title( $events_slug ) ] ) ); + } else { + $link = trailingslashit( bp_loggedin_user_domain() . sanitize_title( $events_slug ) ); + } // Add the "My Account" sub menus $nav[] = array( @@ -35,4 +39,4 @@ function cbox_frontend_adminbar_bpeo() { $GLOBALS['wp_admin_bar']->add_menu( $n ); } } -add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpeo', 45 ); \ No newline at end of file +add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpeo', 45 );