Skip to content

Commit

Permalink
Merge pull request #3 from BenjaminMedia/feature-edit-links
Browse files Browse the repository at this point in the history
Added support for edit topic links
  • Loading branch information
sulfo authored Jan 9, 2017
2 parents 48b4daa + 13c6fa1 commit ca2cce3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bbpress-better-permalinks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Bonnier bbPress better permalinks
* Version: 0.1.4
* Version: 0.1.5
* Plugin URI: https://github.com/BenjaminMedia/bbpress-better-permalinks
* Description: This plugin alters the url structure for topics in bbpress so they belong to the forum they are attached to
* Author: Bonnier - Alf Henderson
Expand Down
9 changes: 8 additions & 1 deletion src/Bonnier/WP/BBPress/BetterPermalinks/Permalinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ public static function add_post_types_rewrite($postType, $args)
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,})/?$',
'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/?$',
'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().'/(.+?)/?$',
'index.php?forumnames=$matches[1]&name=$matches[2]&post_type='.$postType,
Expand Down

0 comments on commit ca2cce3

Please sign in to comment.