Opened 2 years ago
Closed 17 months ago
#16092 closed enhancement (fixed)
add_permastruct() should allow more control over WP_Rewrite::generate_rewrite_rules()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | Rewrite Rules | Version: | 3.0.4 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | admin@…, scribu |
Description
Hi guys,
In wp-includes/rewrite.php the function rewrite_rules calls "generate_rewrite_rules" with default parameters when creating rules for extra_permastructs.
Hence, all extra_permastructs get rules for paging, feeds, walk dirs and all end points, and yet no rules for commenting.
This logic kind of renders the add_permastructs function pointless - it definitely forced me to add my "extra" permastructs manually by using one of the available filters in the rewrite_rules function - since I didn't want any of the rules generate_rewrite_rules creates by default - I only happened to want the comment paging rule.
Wouldn't the logical thing be to allow add_permastructs function callers to decide what rewrite rules they need for each extra permastruct they add?
The attached patch changes the function and class method signatures to:
$args mirrors the arguments that can be passed to generate_rewrite_rules() as well as the old $with_front parameter.
The patch changes the structure of WP_Rewrite::$extra_permastructs, but:
I also added some extra documentation. I was considering on also adding warnings for the 'paged' and 'walk_dirs' which have to stay true by default for back compat, see #19876.
Related: [13438] / #10912, [13773] / #12605, #19871, #16840