Skip to content

Commit a27dddc

Browse files
committed
feat: Add proper cleanup in uninstall.php
1 parent 9864614 commit a27dddc

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

uninstall.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,23 @@
22

33
defined('WP_UNINSTALL_PLUGIN') || exit;
44

5-
// silence is golden
5+
// Remove widget instances
6+
delete_option('widget_latest-post-widget');
7+
8+
// Cleanup sidebar assignments
9+
$sidebars = get_option('sidebar_widgets');
10+
if (is_array($sidebars)) {
11+
foreach ($sidebars as $sidebar => $widgets) {
12+
if (is_array($widget)) {
13+
$sidebars[$sidebar] = array_filter($widgets, function ($widget) {
14+
return strpos($widget, 'latest-post-widget') != 0;
15+
});
16+
}
17+
}
18+
update_option($sidebars);
19+
}
20+
// Clear any transients plugin might have created
21+
delete_transient('latest_post_widget_errors');
22+
23+
// Clear object name
24+
wp_cache_flush();

0 commit comments

Comments
 (0)