I’m unable to find how to disable the default widgets on site creation. By this I mean when I create a site within a WordPress multisite network, it does not create the sidebar widgets such as “meta” automatically.
I see plugins that haven’t been updated in two plus years that may help me with this, but I don’t want to download anything that old.
Does anyone know how to do this?
The default widgets are created by a call to
update_option()
inwp_install_defaults()
inwp-admin/includes/upgrade.php
.After
wp_install_defaults()
has been called bywpmu_create_blog()
inwp-includes/ms-functions.php
, the actionwpmu_new_blog
is fired.You can, therefore, hook into
wpmu_new_blog
and remove the default widgets by callingupdate_option()
again, this time with an empty array forsidebar-1
.I believe unregister_widget is what you are looking for.