how to enable mu-plugins folder within multisite installation
-
Hi support team,
I have used your instructions http://codex.wordpress.org/Must_Use_Plugins to setup a mu-plugins folder via ftp.But the plugins I droped in are not displayed within the admin area of plugins.php page.
Did I missed something to enable or put in to the new folder?
Can you give me instructions to enable that it would work for any plugin droped in, also by using sub-folders?
Kind regards,
Alex
-
“Files in the /wp-content/mu-plugins directory are executed automatically.”
Only *.php files get looked at in mu-plugins, so if your plugins are in a folder they won’t be loaded.
You can add a *.php file into mu-plugins that then loads a php file within a folder.
I offer this example of what I use to load every php file within a folder labeled stj_spam_tools within the mu-plugins folder
<?php $stj_spam_tools = glob(dirname(__FILE__).'/stj_spam_tools/*.php'); if( is_array( $stj_spam_tools ) ) { foreach ( $stj_spam_tools as $stj_spam_tool ) { if( is_file( $stj_spam_tool ) ) include_once( $stj_spam_tool ); } } ?>Oh, and in a multisite, these “must use” plugins are only listed in the Network->Plugins page at /wp-admin/network/plugins.php?plugin_status=mustuse
Hi David,
thanks for answer.
I has almost helped. I used your code and setup a index.php and droped this file into the mu-plugins folder, but instead of plugins who are droped within this folder only the index.php is shown as a plugin.Here a screen shot about the plugins.php
– http://screencast.com/t/Pxs11cZhBwHere a screen shot about the folder where the plugin is droped in. Screen shot
– http://screencast.com/t/VcVjGcSzCiI need to enable the function, that I can see the plugins in use within the mu-plugins folder and without the index.php page indicated as a plugin itself.
Looking forward to your suggestions.
Regards, Alex
You are loading your index,php, that’s good. Those pics all look normal.
I might not name it “index.php”. Name it instead “my_spam_plugin.php”. That way you can see what plugin has been loaded.
Whatever plugins it makes “include_once” should also be active.
Whatever subsequent plugins that load after your initial index.php loader are not listed anywhere, but they should be still active. Every php file in “mu-plugins” is listed, just nothing inside a folder(or within a folder within a folder etc).
You’ll need to test and tweak to make sure your plugin works in its new home. Not every plugin keeps its paths sorted out when you fiddle with it’s location outside the usual /wp-content/plugins/
Hi David,
ok – so if I understood you right, I need following to do.
If I drop other plugins within the mu-plugins folder, then I need to integrate always a new “name-of-plugin.php” and change your code to its plugin dropped in folder, which then refer to its normal (plugin-name).php within sub-folder to enable its original functions behind – am I right?
If so then I have the problem, that in case of my dropped plugin called bp-multi-network is not working by changing your code as stated.
<?php $bp-multi-network = glob(dirname(__FILE__).'/bp-multi-network/*.php'); if( is_array( $bp-multi-network ) ) { foreach ( $bp-multi-network as $bp-multi-network ) { if( is_file( $bp-multi-network ) ) include_once( $bp-multi-network ); } } ?>Then I am getting this error in browser:
Parse error: syntax error, unexpected ‘=’ in (I have full path deleted)./wp-content/mu-plugins/bp-multi-network-index.php on line 2
P.S. My intention is to use the mu-plugin folder similar to the normal plugin folder, where I can drop plugins within sub-folder to be used always activated.
Thanks for your helping hands to solve this.
KR, Alex
Yeah, some php errors there: “$bp-multi-network” not same as “$bp_multi_network”
(I use a code editor that colour codes php and error checks it before saving it over ftp – like having spellcheck for code).
If using syntax /bp-multi-network/*.php the * wildcard is going to load every php file: but you may only want it to include the one bp_multi_network.php file with the actual WordPress plugin header info:
<?php $bp_multi_network = glob(dirname(__FILE__).'/bp-multi-network/bp_multi_network.php'); include_once( $bp_multi_network ); ?>PS: A major disadvantage to dropping entire plugins into /mu-plugins/ is no more update notifications from the repository. Plugins that depend on load order of certain action hooks or globals may be borked too. Anyway, considered using the “Network Activate” to accomplish the same? Loads of advantages to keeping it simple.
Hi David,
Thank you for submitting this code, but this gives me following failure message:
Warning: include_once(Array): failed to open stream: No such file or directory in /home/worldcheckin/public_html/wci.ms/wci/wp-content/mu-plugins/bp-multi-network.php on line 3
Warning: include_once(): Failed opening ‘Array’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/worldcheckin/public_html/wci.ms/wci/wp-content/mu-plugins/bp-multi-network.php on line 3
Well this is really a complex topic which I am not aware how to do (not a programmer)
Are you able to give me advice in how to spellcheck by using e.g. notepad++ to enable a correct version need to be used?
Kind Regards,
AlexYeah, the first warning compares the path and file name you told the code to load with the path and name of the actual file. The two do not agree is all.
The second warning says the variable has nothing in it, which will be corrected when you put the correct path in the code to begin with.
The warning/error is telling you your problem and solution.
Anyway, you have a lot to choose from for php editors. I use Smultron and CyberDuck fairly regularly and Aptana Studio for the heavy duty stuff. Smultron nicely colours code (syntax highlighting) so I can see typo errors right away. I’ve tried many but settled on this combination over the last few years. I don’t use notepad++, but it is on the list and does php syntax highlighting. Give that a whirl.
The topic ‘how to enable mu-plugins folder within multisite installation’ is closed to new replies.