[wp-trac] [WordPress Trac] #36292: Rewrites: Next Generation
WordPress Trac
noreply at wordpress.org
Thu Mar 31 12:04:36 UTC 2016
#36292: Rewrites: Next Generation
-----------------------------+-----------------------------
Reporter: rmccue | Owner: rmccue
Type: feature request | Status: assigned
Priority: normal | Milestone: Future Release
Component: Rewrite Rules | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+-----------------------------
Comment (by giuseppe.mazzapica):
Replying to [comment:7 rmccue]:
> Unfortunately, this isn't true. add_rewrite_rule accepts an array
This is why in my first comment I proposed to add another function
`add_rewrite_callback` (or maybe `add_rewrite_rule_callback`): if it is a
different function, than you always expect a callback and no overlap
possible.
> the hook's description currently "Fires once the WordPress environment
has been set up." which doesn't imply that there's a main query. However,
it's not fired on the admin. I think we need to work out exactly what this
hook should do and document that. It's a useful hook even for non-query
pages as it allows frontend-only events.
Well, the description is wrong :) At the moment, the hook `wp` fires in
frontend and in backend but only where a main WP_Query is used. In short,
if a main query is there, the `wp` hook is fired.
This is why for me it is a query-related hook. When I see `wp` hook I read
instead `main_query_done`. Maybe it was not ''intended to be'' like that,
but actually it ''is''.
Regarding frontend-only hooks, I think that `template_redirect` is the
most fitting in many cases. It's early enough that headers are not sent
and is not fired in admin (or AJAX) requests.
For plugins that needs to do ''stuff'' on frontend, I think that
`template_redirect` is almost always the best choice... unless you need to
override the url->query->template logic, that is the reason why this issue
exists.
> I guess a broader question there is whether the admin should continue to
be regarded as separate, or just another part of the main WP environment.
I suspect the former.
If the url-to-query logic that currently always happen in frontend will
ever changed to a more flexible routing system, than would probably make
sense to convert admin screens to "protected routes". But we have to get
there, first.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36292#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list