'blyzer_event', 'post_status' => array_values(array_unique(array_merge(array_keys(get_post_stati()), ['publish', 'future', 'draft', 'pending', 'private', 'trash', 'auto-draft', 'inherit']))), 'numberposts' => -1, 'fields' => 'ids' ]); foreach ($ids as $_id) { $_id = (int) $_id; Api::deleteAll($_id); wp_delete_post($_id, true); } self::deleteByPrefix(); PostType::removeCaps(); } private static function deleteByPrefix(): void { global $wpdb; $prefixes = ['blyzer_stale_', '_transient_blyzer_', '_transient_timeout_blyzer_']; foreach ($prefixes as $_prefix) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- one-time cleanup on uninstall, WordPress has no API to delete options by prefix. $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like($_prefix) . '%')); } wp_cache_flush_group('blyzer_events'); } }