| @@ -53,4 +53,67 @@ | ||
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | + | |
| 58 | +/* | |
| 59 | + * Analytics state — removed UNCONDITIONALLY, outside the remove_db gate above. | |
| 60 | + * | |
| 61 | + * That gate is a housekeeping preference: "also delete my widget and settings data". Consent is not | |
| 62 | + * housekeeping. Someone who removes the plugin has withdrawn from the data-sharing arrangement, and | |
| 63 | + * leaving the opt-in behind means a reinstall silently resumes sending without ever asking again — | |
| 64 | + * which is the exact behaviour purge_state() exists to prevent. | |
| 65 | + * | |
| 66 | + * suite_key `wdk_suite` has exactly one member, so the suite-wide flag is safe to pass true here: | |
| 67 | + * there is no sibling product whose consent this could reset. | |
| 68 | + */ | |
| 69 | +require_once plugin_dir_path( __FILE__ ) . 'includes/posimyth-sdk/class-posimyth-tracker-wdk.php'; | |
| 70 | + | |
| 71 | +if ( class_exists( 'Posimyth_Tracker_WDK' ) ) { | |
| 72 | + Posimyth_Tracker_WDK::purge_state( true, 'wdk_suite' ); | |
| 73 | +} | |
| 74 | + | |
| 75 | +// Product-specific analytics state purge_state() does not know about. | |
| 76 | +delete_option( 'wdkit_template_imports' ); | |
| 77 | +delete_option( 'wdkit_cloud_usage' ); | |
| 78 | + | |
| 79 | +/* | |
| 80 | + * Widget caches — removed UNCONDITIONALLY, like the analytics state above and for the same reason: | |
| 81 | + * these are derived caches, not user data, so the "also delete my data" preference does not apply. | |
| 82 | + * Rebuilt from disk on demand while the plugin is installed, and meaningless once it is gone. | |
| 83 | + * | |
| 84 | + * Nothing removed these before. The registry options carry the plugin version in their names, so a | |
| 85 | + * site that had been through a few releases accumulated one row per builder per version and an | |
| 86 | + * uninstall left every one of them behind (verified: twelve rows across three versions, plus | |
| 87 | + * wdkit_widget_meta_cache at 32 KB on the QA site). They are written with autoload = false, so this | |
| 88 | + * is housekeeping rather than a performance fix — but "uninstall" should mean it. | |
| 89 | + * | |
| 90 | + * Matched by prefix with a LIKE sweep because the names are version-dependent and this file cannot | |
| 91 | + * know which versions a site has run. Deleted through delete_option() so the option cache is cleared | |
| 92 | + * and the documented hooks fire, which a bulk DELETE would skip. The prefix is written out literally | |
| 93 | + * rather than pulled from includes/abilities/class-wdk-ability-main.php: uninstall.php runs standalone | |
| 94 | + * (WordPress loads it in isolation, with none of the plugin's own files included) and requiring a | |
| 95 | + * 1,200-line abilities loader here to read one string would be the more fragile choice. If that | |
| 96 | + * prefix ever changes, wdesignkit_widget_registry_option_prefix() and this line change together. | |
| 97 | + */ | |
| 98 | +global $wpdb; | |
| 99 | + | |
| 100 | +$wdkit_registry_rows = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- version-dependent option names are only discoverable by pattern. | |
| 101 | + $wpdb->prepare( | |
| 102 | + "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", | |
| 103 | + $wpdb->esc_like( 'wdkit_widget_registry_' ) . '%' | |
| 104 | + ) | |
| 105 | +); | |
| 106 | + | |
| 107 | +if ( ! empty( $wdkit_registry_rows ) ) { | |
| 108 | + foreach ( $wdkit_registry_rows as $wdkit_registry_row ) { | |
| 109 | + delete_option( $wdkit_registry_row ); | |
| 110 | + } | |
| 111 | +} | |
| 112 | + | |
| 113 | +delete_option( 'wdkit_widget_meta_cache' ); | |
| 114 | + | |
| 115 | +// Legacy autoloaded transients from 2.6.4, superseded by the options above. Named per builder, so | |
| 116 | +// they are cleared by name rather than by pattern. | |
| 117 | +foreach ( array( 'elementor', 'gutenberg', 'gutenberg_core', 'bricks' ) as $wdkit_builder_slug ) { | |
| 118 | + delete_transient( 'wdkit_registered_widgets_' . $wdkit_builder_slug ); | |
| 119 | +} | |