How to call plugin function per site in a multisite?

You’re almost there…

If you have this in your plugin:

function sp_echo_site() {
   echo get_site_url();
}

Then you call this function as this:

sp_echo_site();

And this line will run this function in the context of current site.

So you’ll have to do something like this:

if ( function_exists( 'get_sites' ) ) {
    foreach ( get_sites() as $site ) {
        switch_to_blog( $site->blog_id );

        sp_echo_site();

        restore_current_blog();
    }
}