How to set an option for all sites in my Multisite network?

Excuse me if I’m misunderstanding you, but aren’t the functions add_site_option(), update_site_option() and get_site_option() pretty much, they fall back to single site functions, if not used in a multisite environment, only there for the purpose of having network-wide options.


Regarding your need to change a single site option for all sites in your network. Get all sites of the network with wp_get_sites(), which returns an array of arrays. You can use the array to loop through your single sites in your multisite installation. Make use of switch_to_blog() and restore_current_blog() while looping against the $blog_ids. In between the loop after switching and before restoring, use the single site options functions add_option(), update_option() and get_option() as needed.