query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'tpsa\_%\_settings'" ); // Transients (table-exists cache, pending OTPs, cached user count, wizard redirect). $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_tpsa\_%' OR option_name LIKE '\_transient\_timeout\_tpsa\_%' OR option_name LIKE '\_transient\_tpsm\_%' OR option_name LIKE '\_transient\_timeout\_tpsm\_%'" ); // User meta written by the wizard notice, session tracking, the new-address // alert, the audit notice, and the legacy OTP implementation. $meta_keys = array( 'tpsm_dismissed_setup_notice', '_tpsa_otp_code', '_tpsa_last_seen', '_tpsa_known_ips', '_tpsa_audit_notice_dismissed', ); foreach ( $meta_keys as $meta_key ) { delete_metadata( 'user', 0, $meta_key, '', true ); } // Custom log tables. foreach ( array( 's_logins', 'failed_logins', 'block_users', 'threats' ) as $table ) { $name = $wpdb->prefix . 'tpsa_' . $table; $wpdb->query( "DROP TABLE IF EXISTS `{$name}`" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared } // Scheduled cleanup event. wp_clear_scheduled_hook( 'tpsa_cleanup_logs' ); } if ( is_multisite() ) { $tpsa_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $tpsa_site_ids as $tpsa_site_id ) { switch_to_blog( $tpsa_site_id ); tpsa_uninstall_site(); restore_current_blog(); } } else { tpsa_uninstall_site(); }