Skip to content

Fixing Issue #5 - Rewrite Rule Error #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Bonnier/WP/BBPress/BetterPermalinks/Permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,38 @@ public static function after_bbPress_setup()
/**
* Add the forum parents slug structure to bbPress topics
*
* Bugfix by @geefo with admin help from @JHGrove3
*
* @param $postType
* @param $args
*/
public static function add_post_types_rewrite($postType, $args)
{
$topic_slug = get_option( '_bbp_topic_slug', 'topic' );

switch ($postType) {
case bbp_get_topic_post_type():

// Paged topic Rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.bbp_get_topic_slug().'/(.+?)/'.bbp_get_paged_slug().'/([0-9]{1,})/?$',
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/'.bbp_get_paged_slug().'/([0-9]{1,})/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&paged=$matches[3]',
'top'
);
// Edit topic rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.bbp_get_topic_slug().'/(.+?)/edit/?$',
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/edit/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType.'&'.bbp_get_edit_rewrite_id().'=1',
'top'
);
// View topic rule
add_rewrite_rule(
bbp_get_forum_slug().'(.+?)'.bbp_get_topic_slug().'/(.+?)/?$',
bbp_get_forum_slug().'(.+?)'.$topic_slug.'/(.+?)/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType,
'top'
);

add_permastruct($postType, bbp_get_forum_slug()."%forumnames%".get_option( '_bbp_topic_slug', 'topic' )."/%postname%/", $args->rewrite);
add_permastruct($postType, bbp_get_forum_slug()."%forumnames%".$topic_slug."/%postname%/", $args->rewrite);
static::flush_rewrite_rules_if_needed();
break;
}
Expand Down