← All changes
|
includes/abilities/settings/wdesignkit-remove-database.php
+21
-4
2.5.2
→
2.7.0
View file →
| @@ -9,12 +9,12 @@ | ||
| 9 | 9 | exit(); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | wp_register_ability('wdesignkit/remove-database', [ |
| 13 | - 'label' => __('WDesignKit Remove Database', 'sprout-mcp'), | |
| 13 | + 'label' => __('WDesignKit Remove Database', 'wdesignkit'), | |
| 14 | 14 | 'description' => __( |
| 15 | 15 | 'Manages the WDesignKit database-cleanup configuration and can execute an immediate cleanup. "get" reads the current config; "configure" saves which data should be removed on uninstall; "execute" runs the cleanup immediately. Destructive execute requires confirm: true; use dry_run: true to preview.', |
| 16 | - 'sprout-mcp', | |
| 16 | + 'wdesignkit', | |
| 17 | 17 | ), |
| 18 | 18 | 'category' => 'wdesignkit', |
| 19 | 19 | 'input_schema' => [ |
| 20 | 20 | 'type' => 'object', |
| @@ -61,12 +61,18 @@ | ||
| 61 | 61 | 'dry_run' => ['type' => 'boolean'], |
| 62 | 62 | ], |
| 63 | 63 | ], |
| 64 | 64 | 'execute_callback' => 'wdesignkit_mcp_remove_database', |
| 65 | - 'permission_callback' => 'sprout_mcp_permission_callback', | |
| 65 | + 'permission_callback' => 'wdesignkit_mcp_permission_callback', | |
| 66 | 66 | 'meta' => [ |
| 67 | + // action "execute" irreversibly deletes the plugin's stored data, which is the data half | |
| 68 | + // of deleting the plugin — gated on delete_plugins so a multisite site admin (who has | |
| 69 | + // manage_options but not delete_plugins) cannot wipe it. Enforced via | |
| 70 | + // wp_ability_permission_result (WP 7.1+); see class-wdk-ability-lifecycle.php. | |
| 71 | + 'required_capability' => 'delete_plugins', | |
| 72 | + 'public' => false, | |
| 67 | 73 | 'show_in_rest' => true, |
| 68 | - 'mcp' => ['public' => true], | |
| 74 | + 'mcp' => ['public' => false], | |
| 69 | 75 | 'annotations' => [ |
| 70 | 76 | 'instructions' => implode("\n", [ |
| 71 | 77 | 'Manages WDesignKit database cleanup.', |
| 72 | 78 | 'action "get": returns current remove_db config (default if action omitted).', |
| @@ -226,8 +232,19 @@ | ||
| 226 | 232 | 'wdkit_dark_mode', |
| 227 | 233 | 'wdkit_wintersale_notice_dismissed', |
| 228 | 234 | 'wdkit_rating_banner_start_date (all users)', |
| 229 | 235 | ]; |
| 236 | + } | |
| 237 | + | |
| 238 | + // Both branches above delete wkit_deactivate_widgets, and the cached widget registry bakes | |
| 239 | + // that option's membership in. The cache is a no-expiry transient, so without this the | |
| 240 | + // widgets the reset was meant to re-enable stayed unregistered indefinitely | |
| 241 | + // (ClickUp 86d41cd18 — same root cause as the admin activate/deactivate path, 86d41cck1). | |
| 242 | + if (($new_config['widget_builder_data'] || $new_config['all_data']) | |
| 243 | + && function_exists('wdesignkit_invalidate_widget_registry')) { | |
| 244 | + foreach (['elementor', 'gutenberg', 'gutenberg_core', 'bricks'] as $builder_slug) { | |
| 245 | + wdesignkit_invalidate_widget_registry($builder_slug); | |
| 246 | + } | |
| 230 | 247 | } |
| 231 | 248 | } |
| 232 | 249 | |
| 233 | 250 | return [ |