I have developed a WordPress plugin, and one of the widgets in the plugin has a spelling error in the $id_base
param of the parent::__construct
method called in the Widget constructor. It seems that fixing the spelling error removes any instance of the widget currently in place. Is it possible to change the $id_base
for the widget without breaking current instances of the widget?
You can deprecate the whole function which will probably be quite hard to do in your situation but it is possible with some work:
You could check for both, but load the new one for future installs:
function badly_named() {
__doing_it_wrong( 'badly_named', 'This method has been deprecated in favor of better_named_function' );
/**
* Call the better named method
*/
better_named_function();
}
-
Thanks for the feedback @JohanPretorius. I'd prefer to avoid deprecating anything if possible. Another option I was considering was using the constructor for the widget deregister itself, and then register the new widget. I am not sure that this would work though. – Brady Charron Oct 10 '19 at 13:06
$id_base
, so you'd need to make sure they're aware of the$id_base
change (like a grace period for letting them update their code). So either keep the typo.. change it.. or maybe as the answer suggested, deprecate the old widget. – Sally CJ Oct 11 '19 at 4:35