Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
BBP_Forums_Group_Extension::maybe_map_permalink_to_group( int $post_id, $url = false )
Maybe map a bbPress forum/topic/reply permalink to the corresponding group
Description Description
Parameters Parameters
- $post_id
-
(Required)
Return Return
(Bail) early if not a group forum post
Source Source
File: includes/extend/buddypress/groups.php
private function maybe_map_permalink_to_group( $post_id = 0, $url = false ) { switch ( get_post_type( $post_id ) ) { // Reply case bbp_get_reply_post_type() : $topic_id = bbp_get_reply_topic_id( $post_id ); $forum_id = bbp_get_reply_forum_id( $post_id ); $url_end = trailingslashit( $this->reply_slug ) . get_post_field( 'post_name', $post_id ); break; // Topic case bbp_get_topic_post_type() : $topic_id = $post_id; $forum_id = bbp_get_topic_forum_id( $post_id ); $url_end = trailingslashit( $this->topic_slug ) . get_post_field( 'post_name', $post_id ); break; // Forum case bbp_get_forum_post_type() : $forum_id = $post_id; $url_end = ''; //get_post_field( 'post_name', $post_id ); break; // Unknown default : return $url; } // Get group ID's for this forum $group_ids = bbp_get_forum_group_ids( $forum_id ); // Bail if the post isn't associated with a group if ( empty( $group_ids ) ) { return $url; } // @todo Multiple group forums/forum groups $group_id = $group_ids[0]; $group = groups_get_group( array( 'group_id' => $group_id ) ); if ( bp_is_group_admin_screen( $this->slug ) ) { $group_permalink = trailingslashit( bp_get_group_admin_permalink( $group ) ); } else { $group_permalink = trailingslashit( bp_get_group_permalink( $group ) ); } return trailingslashit( trailingslashit( $group_permalink . $this->slug ) . $url_end ); }
Changelog Changelog
Version | Description |
---|---|
2.2.0 | Introduced. |