add_rewrite_endpoint generates incorrect attachment rules
|Reported by:||batmoo||Owned by:||duck_|
|Cc:||batmoo, info@…, knut@…, LucasMS|
add_rewrite_endpoint with EP_ALL or EP_ATTACHMENT results in incorrect endpoint matches. The index set for the endpoint value is 2 which ends up returning the slash as well. The index should actually be 3 since we only care about the inner match.
add_rewrite_endpoint( 'my-endpoint', EP_ALL )
Results in rules like (dump from $wp_rewrite->generate_rules:
'.?.+?/([^/]+)/my-endpoint(/(.*))?/?$' => string(35) "index.php?attachment=$1&my-endpoint=$2" '.?.+?/attachment/([^/]+)/my-endpoint(/(.*))?/?$' => string(35) "index.php?attachment=$1&my-endpoint=$2"
Visiting a my-endpoint URL for an attachment like /2012/01/01/post-name/attachment/my-endpoint/foo/ will return the value of get_query_var( 'my-endpoint' ) as /foo instead of foo.
Change History (8)
- Keywords has-patch added
- Milestone changed from Awaiting Review to Future Release
- Owner set to duck_
- Resolution set to fixed
- Status changed from new to closed