Widgets Loaded Late?
-
I’ve come across a bug while developing the latest version of my plugin: when using a class for plugin functions it is impossible to call Widget register functions from inside a class if that class is not instantiated to a variable.
If I do $foo = new Class(); I can call the Widget functions from inside the classes functions. If I do Class::function(); then it cannot see the widget registering function inside and dies with a ‘Call to undefined function wp_register_sidebar_widget()’ error.
Looking into it (check default-filters.php) it appears that the Widgets are only being loaded after plugins have loaded…
add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
…which seems a pretty bad idea as the plugins depend on the Widgets. Not sure why this error does not show up when the class is instantiated.
What is the intended result of loading Widgets this late?
- The topic ‘Widgets Loaded Late?’ is closed to new replies.