Skip to content

Commit

Permalink
Use bp_members_get_user_url() instead of _user_domain() functions.
Browse files Browse the repository at this point in the history
See #458.
  • Loading branch information
boonebgorges committed Nov 18, 2024
1 parent c964350 commit f272c51
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 6 additions & 2 deletions includes/frontend-adminbar-bbpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) {
Expand Down
14 changes: 10 additions & 4 deletions includes/frontend-adminbar-bpdocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 );
add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpdocs', 80 );
8 changes: 6 additions & 2 deletions includes/frontend-adminbar-bpeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 );
add_action( 'bp_setup_admin_bar', 'cbox_frontend_adminbar_bpeo', 45 );

0 comments on commit f272c51

Please sign in to comment.