get_blog_prefix($siteId)) * @return list the exact names of that site's Aiwend tables (empty for a prefix that is not a plain WordPress table prefix) */ public static function forPrefix(string $blogPrefix): array { if ($blogPrefix === '' || preg_match('/^[A-Za-z0-9_]+$/D', $blogPrefix) !== 1) { return []; } $names = []; foreach (Uninstaller::TABLES as $suffix) { $names[] = $blogPrefix . 'aiwend_' . $suffix; } return $names; } /** * WordPress's own list of tables to drop, extended by the site's Aiwend tables. Tables that do not exist are harmless (WordPress * runs DROP TABLE IF EXISTS), so a site that never had Aiwend, or one whose cleanup ran before, is fine. * * @param array $tables the list WordPress passes to the filter * @return list */ public static function extend(array $tables, string $blogPrefix): array { $own = []; foreach ($tables as $table) { if (is_string($table) && $table !== '') { $own[] = $table; } } return array_values(array_unique(array_merge($own, self::forPrefix($blogPrefix)))); } }