[wp-trac] [WordPress Trac] #22110: Check for current conditional
WordPress Trac
wp-trac at lists.automattic.com
Fri Oct 5 17:36:54 UTC 2012
#22110: Check for current conditional
-------------------------+------------------------------
Reporter: mintindeed | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by mintindeed):
Replying to [comment:1 scribu]:
> Can't you just use get_body_class()?
Honestly I hadn't considered that, I was mostly aware of body_class()
which of course just outputs a space-delimited string.
get_body_class() looks like it would mostly work, but there are some core
differences:
* rtl is the first element of the array when is_rtl() is set, so if I
wanted to use this to a theme (for example) I would have to do some funky
workarounds to account for rtl support — the first element of the array
wouldn't always be the primary section of the site.
* it wouldn't work if you needed to programmaticallly find "where am I" in
a feed, or anywhere that's not really user-facing.
* no clear identifier that you're on a custom taxonomy, e.g. the second
element is "tax-<taxonomy name>" so when you just want to know whether
you're on a custom taxonomy page you have to do some custom parsing.
You're right that get_body_class() would work better than the hacky way I
currently get the current section, for the most part.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22110#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list