I am creating a custom MU plugin to run on a multi-site network. I am working on a function that will dynamically include files containing additional action and filter hooks based on the active plugins for the current website being processed. The problem is, my function is not called when I visit a child site. Only the main site fires this event. How can I get it to execute the function regardless of the site I am on?
function my_plugin_autoload_plugin_hooks() {
$active_plugins = get_option('active_plugins');
// Include custom files from my plugin if they appear in the $active_plugin list.
}
add_action('plugins_loaded', 'my_plugin_autoload_plugin_hooks');
I am creating a custom MU plugin to run on a multi-site network. I am working on a function that will dynamically include files containing additional action and filter hooks based on the active plugins for the current website being processed. The problem is, my function is not called when I visit a child site. Only the main site fires this event. How can I get it to execute the function regardless of the site I am on?
function my_plugin_autoload_plugin_hooks() {
$active_plugins = get_option('active_plugins');
// Include custom files from my plugin if they appear in the $active_plugin list.
}
add_action('plugins_loaded', 'my_plugin_autoload_plugin_hooks');
Share
Improve this question
asked Oct 12, 2014 at 20:50
AdamAdam
3495 silver badges13 bronze badges
5
|
1 Answer
Reset to default 1With Multisite, you need to use add_site_option/get_site_option instead of add_option/get_option.
https://codex.wordpress/Function_Reference/get_site_option
wp_die('howdy');
, for example? – s_ha_dum Commented Oct 12, 2014 at 23:12exit( '<h1>HELLO!</h1>' );
to your plugin to see if it triggers. Else your setup (wp-config.php
and the directories) will have to be shown in the question - edit please - because then only those, in theory, should be able to affect your setup. – kaiser Commented Oct 15, 2014 at 11:48