blog_id ); self::activate_site(); restore_current_blog(); } /** * Runs a callback on the current site, or on every site of the network. * * @param bool $network_wide Whether to run it on every site. * @param callable $callback What to run on each site. */ public static function each_site( bool $network_wide, callable $callback ): void { if ( ! $network_wide || ! is_multisite() ) { $callback(); return; } $site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $site_ids as $site_id ) { switch_to_blog( (int) $site_id ); $callback(); restore_current_blog(); } } }