Opened 16 years ago
Closed 15 years ago
#16092 closed enhancement (fixed)
add_permastruct() should allow more control over WP_Rewrite::generate_rewrite_rules()
| Reported by: | dnxpert | Owned by: | John |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | Rewrite Rules | Version: | 3.0.4 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The attached patch changes the function and class method signatures to:
$argsmirrors 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