Normally, you can add code snippets for your custom functions into functions.php
which is placed in your theme or child theme folder. But in case you select “mu-plugins” (ip-location-block-mu.php) as “Validation timing” in “Validation rule settings” section, your code for this plugin in functions.php
would be failed to work as you expected.
This restriction is originated from the excution order described in Action Reference where you can find muplugins_loaded
action hook is triggered far before after_setup_theme
which is the timing of your functions.php
to be parsed.
Then what’t the solution?
Installing “drop-in.php” and “drop-in-admin.php”
To install, upload drop-in.php
or drop-in-admin.php
in /wp-content/uploads/ip-location-block/dropins/
You can find a sample for drop-in.php
in /wp-content/plugins/ip-location-block/wp-content/drop-in-sample.php
. Just rename it to dropi-in.php and upload in the directory mentioned above.
Both drop-in.php
and drop-in-admin.php
are similar but are fired on different sides. The first is used on the front-end and the second is used on the admin side.
Note that even in the case of multisite, drop-in.php
and drop-in-admin.php
will be called on every site. So if you want each site to behave differently, you should add some code like follows:
functions.php
doesn’t need to be put together into drop-in.php
but functions related to only this plugin such as Filter hooks for this plugin.