query($wpdb->prepare('DROP TABLE IF EXISTS %i', $wpdb->prefix . $fssl_table)); } // Sweep options by prefix, so none is left behind (alert emails, a webhook URL with a token). // Every option and transient carries the plugin's own prefix, so the sweep touches no one else's. $fssl_prefixes = [ 'fssl_', '_transient_fssl_', '_transient_timeout_fssl_', ]; foreach ($fssl_prefixes as $fssl_prefix) { $fssl_pattern = $wpdb->esc_like($fssl_prefix) . '%'; $fssl_names = $wpdb->get_col( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- core table name; the pattern is bound. $wpdb->prepare("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $fssl_pattern) ); foreach ((array) $fssl_names as $fssl_name) { // fssl_version is kept so a reinstall recognises the retained attestation log. if ($fssl_name !== 'fssl_version') { delete_option($fssl_name); } } } }; // On a network each site that installed ScriptLedger has its own tables, settings and job queue. if (is_multisite()) { foreach (get_sites(['fields' => 'ids', 'number' => 0]) as $fssl_site) { switch_to_blog((int) $fssl_site); // The install date is written before the schema check, so a site whose first install failed counts. $fssl_installed = get_option('fssl_version', false) !== false || get_option('fssl_installed_at', false) !== false; if ($fssl_installed) { $fssl_uninstall(); } restore_current_blog(); } } else { $fssl_uninstall(); }