I want to write a simple Wordpress plugin for Wordpress Multisite and am using the WPBP template. I am not sure how I create code that runs in the master (Network) portion, or how I can make it run only on one site.
My questions are:
I am planning to place everything into a class. Should I instantiate the class in the main (global) portion of the plugin file, or only in the callback method?
How do I make my code run only on one of my sites (of the multisite)? How can I make it run for all sites?(Do I need to do a PHP check for a URI?
I want to write a simple Wordpress plugin for Wordpress Multisite and am using the WPBP template. I am not sure how I create code that runs in the master (Network) portion, or how I can make it run only on one site.
My questions are:
I am planning to place everything into a class. Should I instantiate the class in the main (global) portion of the plugin file, or only in the callback method?
How do I make my code run only on one of my sites (of the multisite)? How can I make it run for all sites?(Do I need to do a PHP check for a URI?
1 Answer
Reset to default 0Depending on what you're doing, generally the code will only run on one site at a time. Multi site blogs have a "blog id". Most WP code will simply assume that you're referring the the current running site.
Each site has the ability to enable the plugin, or you can enable it for your entire network.