I’m developing the wordpress file monitor plus plugin.
Its purpose is to scan for altered files and it works fine for a single installation of WP. But when you look at multi-site it’s not something that wants to be enabled on all sub sites, as they all share the same files and (to be honest) only a network admin should be the one that wants to be notified against file changes.
So my question is this:
How would I program it, to only be allowed to be installed/run from the root site of a multi-site installation? So: that means not allowing it to be network installed and only activated from the root blog.
Anyone know of any ways on how I could achieve this?
You could check if the constant
SITE_ID_CURRENT_SITE
matchesget_current_site()->id
. The following does this for the activation. During runtime you have to check it again.First the explanation for the uninstall/activation/deactivation hooks.
Second: check for
is_blog_installed( $blog_ID );
and then look into all theget_blog_whatever();
and get_blogaddress_whatever();` functions (I guess you use phpstorm as IDE, so autocomplete for functions should be available to you).Edit: You could also try to restrict the available menu with registering the admin pages with
network_admin_menu()
(triggers only ifis_network_admin()
),user_admin_menu();
(triggers only ifis_user_admin()
) instead ofadmin_menu();
.Only this solution worked for me :