Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm a little confused about when I should be placing plugin files into mu-plugins. I know it's Must-Use plugins and I know that they are automatically enabled.

In the network setting, though, does this force the plugin file to be enabled in all child blogs? Makes sense that it would, so is that the only time I should put a plugin file THERE in a network? When I want the plugin code to be run in each child blog?

For example, if I wanted to automatically set a new thumbnail size, should I do this there?

Or are there other examples.

And what about network activate?

share|improve this question

1 Answer 1

The mechanic is the same in Single and Multisite installations.

And yes, the plugins inside mu-plugins will be activated in the entire Network.

To enable a new thumbnail size in all the sites except the one with ID equal to 3:

global $blog_id;
if( $blog_id != 3 )
    add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)

Reading the Codex we also learn that:

WordPress only looks for PHP files right inside the mu-plugins directory, and (unlike for normal plugins) not for files in subdirectories. You may want to create a proxy PHP loader file inside the mu-plugins directory:

<?php 
// mu-plugins/load.php
require WPMU_PLUGIN_DIR.'/my-plugin/my-plugin.php';

Just in case, I have this observation in my testing plugin inside mu-plugins:

// USEFUL FOR SOME STUFF THAT DON'T RUN IN THIS MU-MODE
add_action('plugins_loaded', 'brsfl_late_init');

function brsfl_late_init() {
    //add_filter( 'attachment_fields_to_edit', 'fb_attachment_fields_edit', 10, 2);
    //add_filter( 'attachment_fields_to_save', 'fb_attachment_fields_save', 10, 2);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.