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?
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?
1 Answer
Reset to default 0You 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();
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745098964a4611157.html
$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 Commented Oct 11, 2019 at 4:35