Since the new plugin version, the widgets on my subpages failed. There I controlled the widget display by Widget Logic and an own function is_parent() which uses get_post_ancestors(). Replacing the page ID with the page object (as recommended in post by mmikkel) did work on one site. But on another this did not work anyway. There is also a ticket in the WordPress core trac. This gives the hint that the function get_post_ancestors() has sometimes caching problems. And that is, what I suspect, the final reason for my widget problems.
In the last days I’ve analysed the new plugin implementation a bit and found a quite strange behaviour.
When using the old version 0.48 the widget logic is executed exactly one time for each widget. With the new version and exactly the same widget configuration on a freshly resetted wp3.3.1 installation the widget logic for one widget is executed 9 times. The first execution already before the get_header() function. At this point no post ID is provided.
(Only the plugins “Widget Logic” and the debug plugin “Electric Studio Logger” were enabled.)
When the widget logic is called the first time no post ID is provided and in some cases get_post_ancestors() probably caches an empty result for subsequent requests. After replacing the function with an alternative algorithm (based on direct mysql database requests) the widgets are displayed correctly, but there is still the multiple execution of the widget logic for a single widget.
I stepped back to Widget Logic v0.48 for now and hope that the new version may be improved to work properly. Without doubt, the concept of the new version is the better.
- The topic ‘[Plugin: Widget Logic] Strange behaviour of new implementation’ is closed to new replies.