I have created a function on the main site in my multisite network that loops through each site in the network, pulls the values from their options page in ACF, and saves the data to a JSON file. However, I am unsure about how to get it to run outside of a single .php page that I've tested.
My questions are:
- When is the best time to run this function?
- Is the easiest method putting it in a custom plugin and giving it a button to click to run?
- Is there any way I can automate the process, as ideally I would like it to run either when a new site is added to the network or the ACF options of an existing site change?
One issue I have is that my main site and subsites are on separate themes and don't share the same functions.php file, so I don't think using something like acf/save_post would work.