'ids', 'number' => self::SITE_BATCH_SIZE, 'offset' => $offset, 'orderby' => 'id', ] ); if ( empty( $siteIds ) ) { self::deleteUserPreferences(); return; } foreach ( $siteIds as $siteId ) { switch_to_blog( (int) $siteId ); self::cleanCurrentSite(); restore_current_blog(); } $offset += self::SITE_BATCH_SIZE; } } private static function cleanCurrentSite(): void { Capabilities::revokeFromAllRoles(); self::deleteAllForms(); EntriesTable::drop(); } private static function deleteAllForms(): void { global $wpdb; while ( true ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- uninstall must see every status (trash, auto-draft included), which get_posts() does not return together. $ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s LIMIT %d", FormPostType::POST_TYPE, self::POST_BATCH_SIZE ) ); if ( empty( $ids ) ) { return; } $deleted = 0; foreach ( $ids as $id ) { if ( wp_delete_post( (int) $id, true ) ) { $deleted++; } } // Silinməsi mümkün olmayan sətir qalarsa eyni dəstə sonsuz // təkrarlanardı: irəliləyiş dayandısa dövrəni burax. if ( 0 === $deleted ) { return; } } } /** * User meta şəbəkə üzrə bir cədvəldədir — hər sayt üçün yox, BİR dəfə silinir. * `is_multisite()`-dən sonra çağırılır: `UninstallTest` faylın ilk WordPress * çağırışının `is_multisite` olduğunu yoxlayır. */ private static function deleteUserPreferences(): void { delete_metadata( 'user', 0, EntryPreferences::META, '', true ); } }