| bio | website | garygale.com |
|---|---|---|
| location | London | |
| age | ||
| visits | member for | 8 months |
| seen | Nov 1 '12 at 8:10 | |
| stats | profile views | 2 |
Husband, Father, coffee addict, Scifi and Electronica fan, UNIX and Mac user and in my day job I'm Director of Places at Nokia Location & Commerce.
|
Mar 25 |
awarded | Self-Learner |
|
Oct 17 |
awarded | Citizen Patrol |
|
Oct 13 |
answered | A hook that runs only when the theme is previewed |
|
Oct 13 |
answered | How can I use the Fresh & Clean theme for blogging? |
|
Oct 11 |
awarded | Supporter |
|
Oct 11 |
comment |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? It seems to. I've thrown it against several plugins that use the_content or the_excerpt within a widget, plus a couple of themes that also use these filters to do idebar or footer tricks and so far, it works. Of course, this is far from a complete and authoritative test, but that's a real challenge given the multiplicity of combinations from WordPress core plus plugins plus themes out there on the interwebs. |
|
Oct 11 |
awarded | Teacher |
|
Oct 11 |
answered | How To Determine If A Filter Is Called In A Sidebar/Widget Context? |
|
Oct 10 |
awarded | Editor |
|
Oct 10 |
revised |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? Added further investigations based on suggestion to use is_main_query() |
|
Oct 10 |
comment |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? So this doesn't seem to be working for me. I would expect is_main_query() to return true when called in the context of the main WordPress Loop and return false when called elsewhere, ie: in the sidebar. But it's returning true under all circumstances. See the EDIT to the original question for what I'm seeing. |
|
Oct 10 |
comment |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? This definitely seems to be one to file under you learn something new every day. Two points. One; I never even thought to look at the query. Two; I'm going to check this out right now. Will report back. Thank you. |
|
Oct 10 |
comment |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? @kaiser - that's true but doesn't help here; the problem is that my code doesn't control when the filter hook is fired, so I'm not looking to fire the hook outside of the Loop (you're right that I can manually fire the hook via apply_filters). To clarify, I'm looking to detect within the hook function itself what context the hook is running in, where the context is either "you're in the sidebar" or "you're not in the sidebar". |
|
Oct 10 |
comment |
How To Determine If A Filter Is Called In A Sidebar/Widget Context? I did look at this, but the problem is that in 99.9% of cases, the the_excerpt filter hook will be fired by a call to apply_filters from within the context of the the_excerpt() API call and the Codex states that the_excerpt() must be called within The Loop. Ditto for the the_content filter hook and the_content() API call. There is a caveat that someone may be doing some query cleverness which effectively duplicates the Loop environment but that's not the case here. So sadly in_the_loop() will always return true in the main Loop and sidebar Loop(s). |
|
Oct 10 |
awarded | Student |
|
Oct 10 |
asked | How To Determine If A Filter Is Called In A Sidebar/Widget Context? |