delete widget upon uninstall

I developped a plugin that makes use of the widgets. It is compatible with both pre-5.8 WordPress widgets (legacy widgets) and the new block editor widgets. The widgets of my plugin do nothing but adding shortcodes.

I was wondering if there is a way to delete widgets upon uninstall? I use an uninstall.php file to clean the user's WP, and would like to also remove the widgets upon uninstall. There is no valid reason for the user to keep them after uninstall.

I tried to find a way, but the only information I can find is about unregistering the widgets. Not about actually deleting them.

Thanks in advance for your help!

Topic uninstallation widgets Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.