From 280757c6d3d9c98fba00dcaaffe8255c50660a85 Mon Sep 17 00:00:00 2001 From: Boone B Gorges Date: Fri, 15 Nov 2024 14:30:27 -0600 Subject: [PATCH] Use `bp_get_group_url()` where possible. See #458. --- includes/frontend-bbpress.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/frontend-bbpress.php b/includes/frontend-bbpress.php index d63c6cf..fe3d3b0 100644 --- a/includes/frontend-bbpress.php +++ b/includes/frontend-bbpress.php @@ -192,7 +192,14 @@ public function fix_group_forum_action( $located, $template_name ) { * @return string */ public function override_the_permalink_with_group_permalink( $retval = '' ) { - return bp_get_group_permalink() . 'forum/'; + if ( function_exists( 'bp_get_group_url' ) ) { + return bp_get_group_url( + groups_get_current_group(), + bp_groups_get_path_chunks( [ 'forum' ] ) + ); + } else { + return bp_get_group_permalink() . 'forum/'; + } } /** @@ -521,7 +528,14 @@ public function fix_pending_group_topics() { $slug = bbp_add_view_all( sprintf( '%s%d', $pending_slug_prefix, $topic_id ), true ); } - return trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . 'forum/topic/' . $slug . $topic_hash; + if ( function_exists( 'bp_get_group_url' ) ) { + return bp_get_group_url( + groups_get_current_group(), + bp_groups_get_path_chunks( [ 'forum', 'topic', $slug ] ) + ) . $topic_hash; + } else { + return trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . 'forum/topic/' . $slug . $topic_hash; + } }, 20, 3 ); // Fix redirect link after pending topic is approved.