[wp-trac] Re: [WordPress Trac] #9952: Unregistering default widgets
is not backwards compatible
WordPress Trac
wp-trac at lists.automattic.com
Thu May 28 21:13:23 GMT 2009
#9952: Unregistering default widgets is not backwards compatible
--------------------------+-------------------------------------------------
Reporter: mtdewvirus | Owner: azaozz
Type: defect (bug) | Status: new
Priority: high | Milestone: 2.8
Component: Widgets | Version: 2.8
Severity: normal | Keywords: widgets
--------------------------+-------------------------------------------------
Comment(by azaozz):
Replying to [comment:7 ryan]:
> ... It reveals another problem in the example above. sapphire tries to
re-register the pages widget with the no longer existing
wp_widget_pages_control() callback.
Yes, exactly. Found couple of other widgets that do the same. That's why I
thought it is better to not register single widgets that are replacing
default widgets.
We are registering default widgets with hook priority of 100, so if we
want to keep these widgets, we could do something like:
{{{
function _register_widgets() {
global $wp_registered_widgets;
$keys = array_keys($this->widgets);
$registered = array_keys($wp_registered_widgets);
foreach ( $keys as $key ) {
// don't register new widget if old, single widget with
the same id is already registered
if ( in_array($this->widgets[$key]->id_base, $registered,
true) )
continue;
$this->widgets[$key]->_register();
}
}
}}}
We should probably do an `is_callable` check on registering a widget and
skip any widget that fails, making sure to unregister it from all globals.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9952#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list