userblog_id, static function () use ( $user_id ): void { VoteRepository::anonymise_user( $user_id ); } ); } } /** * Runs a task on a site of the network, when the plugin is set up there. * * @param int $site_id ID of the site. * @param callable $task What to do there. * @phpstan-param callable(): void $task */ private static function on_site( int $site_id, callable $task ): void { $elsewhere = is_multisite() && get_current_blog_id() !== $site_id; if ( $elsewhere ) { switch_to_blog( $site_id ); } // A site where the plugin was never active has no tables. if ( get_option( Installer::OPTION_DB_VERSION ) ) { $task(); } if ( $elsewhere ) { restore_current_blog(); } } }