[wp-hackers] Avoiding Side-effects in Filters & Actions
Jeremy Clarke
jer at simianuprising.com
Sun Apr 5 21:42:22 GMT 2009
Mike, I think that you're probably doing more work than you need to. I
don't want to just repeat what's already been said, but it sounds like
most of what you need is available from the is_x() functions like
is_page() and is_date(). The actual class that is used is the
$wp_query object. It's not perfect, and unfortunately there's no
canonical $wp_query->type variable that would hold something like
'category', but instead there are just all the different variables
that define the context and they are accessed indirectly using the
is_type() functions. It would be really hard and IMHO barely useful to
have a overarching text description of the current context because of
things like category archives that are also paged, or
date-page-category archives (?cat=3&m=200809&paged=2) that would make
it really complicated. I'm not sure why you would be parsing the query
string yourself, that sounds completely wrong, as its already done by
core and fit into the $wp_query object.
Another part of your problem would probably be solved using custom
fields. What I do is just write my own is_x() functions that check
custom fields (or categories, or whatever) and work them into my logic
along with the core ones. Admittedly its not perfect but I think the
problems your having are going to be there no matter what, it just
comes with the territory unless you expect a full-on UI for managing
all the contextual content blocks (and my experiences with Drupal make
me pretty skeptical that that is any easier to manage than php is_x()
functions unless you don't know any php).
--
Jeremy Clarke | http://simianuprising.com
Code and Design | http://globalvoicesonline.org
More information about the wp-hackers
mailing list