#16840 closed enhancement (fixed)
add_rewrite_rule() should accept an array for the $redirect parameter
Reported by: | scribu | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Rewrite Rules | Keywords: | has-patch needs-testing has-unit-tests |
Focuses: | Cc: |
Description
The most common usage of add_rewrite_rule()
looks something like this:
add_rewrite_rule( 'some/path/([^/]+)/?$', 'index.php?some_var=$matches[1]&maybe_some_flag=1' );
That's not very pretty.
Here's what it could look like instead:
add_rewrite_rule( 'some/path/([^/]+)/?$', array( 'some_var' => '$matches[1]', 'maybe_some_flag' => 1 ) );
In the rare case when you want to use something other than 'index.php' in the front (i.e. an external rule), you can either fall back to the old form or just use add_external_rule().
Attachments (4)
Change History (15)
#7
@
9 years ago
- Keywords needs-testing has-unit-tests added; needs-refresh needs-unit-tests removed
- Owner set to DrewAPicture
- Status changed from new to accepted
#8
@
9 years ago
- Owner changed from DrewAPicture to wonderboymusic
- Status changed from accepted to assigned
#9
@
9 years ago
16840.3.diff adds stricter checks in the tests after feedback from @boonebgorges.
Note: See
TracTickets for help on using
tickets.
16840.2.diff updates the patch including docs and adds tests both for the
add_rewrite_rule()
wrapper andWP_Rewrite::add_rule()
.