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.

We are creating an internal network of sites using MU and there are some small things we would like to have globally on all the sites without having to add them individually for each site. I would like to add a block of JavaScript and CSS that will execute on every site. What's the best way of going about this?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Your answer, Kyle, is the mu_plugins folder. Create it within wp-content. Any php file put in here will be automatically loaded into ALL multisite blogs (or any non-multisite blogs).

This is a great area to put plugins vital to the site working, or shared functionality such as custom post types, taxonomies, filters, etc. Really anything! The main bonus here is when updated said "shared" files, you don't have to do it in every single theme that utilizes it! It'll be available for all themes, on all sites.

If you want to sort your stuff within mu_plugins just put everything in a nice folder structure, and create a index.php or load.php in the root of mu_plugins where you can load everything in.

From there, wp_enqueue_script just as you normally would!

share|improve this answer
    
I'm not new to WordPress usage (but not a poweruser either) but am new to WordPress programming. This sounds like a great option and definitely what I'm looking for. I know roughly some of the hooks and events that WP uses so I will research them further in light of your response, Eric. Thank you! –  Kyle Hayes Jul 10 '13 at 18:22
    
No Problem! Please mark this as solved. –  Eric Holmes Jul 10 '13 at 19:47

You should be able to register these styles and scripts in a shared plugin file, and enqueue them from within the site functions.php. Alternatively, you may attach them in the individual functions.php in the site themes you desire. In that case, remember to wrap them in conditionals in case they are not activated, found, or should you wish to manage them through some other mechanism.

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.