When registering a new class to represent a widget of the same name, make sure to unregister the first widget before registering the new widget.

[code language="php"]
add_action( ‘widgets_init’, function() {
// Doing it right
unregister_widget( ‘Plugin_Widget’ );
register_widget( ‘My_NamespacePlugin_Widget’ );
}, 11 );
[/code]

If you don’t, WordPress will continue to¬†use the update callback for the first widget class. Lovely.

Hand Built is Daniel Bachhuber, an effective developer with technology leadership you can trust.

How can I help?

Hit me at [email protected] with a short note about what you'd like to do.

My roots are WordPress and publishing, and I love pretty much everything related to web development (architecture, performance, security, etc.). When not working with clients, I also maintain WP-CLI (WordPress' command line interface) and other open source projects.