WORDPRESS MUST-USE PLUGINS by Ronald Huereca Presented at WordCamp Norway January 14th, 2012
WHAT IS A MUST-USE PLUGIN?It’s a plugin that cannot be disabled.
WHY USE MU-PLUGINS?• Forcritical functionality that must not be disabled (Custom Post Types, taxonomies)• For network-wide functionality in Multisite networks that even Network Admins can’t disable• Snippetsof code you can re-use independent of regular plugins and themes
BENEFITS OF MU-PLUGINS• Cannot be disabled. Ever. Nunca. Aldri.• Cannot be edited.• Easy to drop in.
DRAWBACKS OF MU-PLUGINS• Cannot be disabled. Ever.• Thereare no automatic updates, so the code must be maintained by you.• No activation hooks are run.• MU-Pluginsdo not have the regular folder structure as a regular WordPress plugin does.• You can bring an entire network down with one PHP error.
wordpress WHERE TOINSTALL AN wp-contentMU-PLUGIN plugins inside wp-content uploads themes
wordpressIF THE MU-PLUGIN FOLDER wp-contentDOESN’T EXIST,CREATE IT plugins mu-plugins
ADD A .PHP FILE mu-pluginsAND HAVESOME FUN run-me-always.php
INSIDE AN MU-PLUGIN <?php //Uhm, just place some code here. ?>
YOU COULD GO A LITTLE MORE COMPLICATED <?php /* Plugin Name: Metronet Tasks Plugin URI: http://www.metronet.no Description: A task manager for WordPress Author: Metronet Version: 1.0 Requires at least: 3.3 Author URI: http://www.metronet.no */ require_once( metronet_tasks/metronet_tasks.php ); ?>
THE LAST mu-pluginsEXAMPLEASSUMES A run-me-always.phpDIRECTORY metronet_tasksSTRUCTURELIKE THIS: metronet_tasks.php
WHAT I’VE USED MU-PLUGINS FOR• Initializing Custom Post Types and taxonomies• Handling redirects• Removing admin menus• Removing dashboard widgets• Disabling the admin-bar on the front-end for all users
ALL OF THESE PLUGINS CAN BE WRITTEN AS REGULAR PLUGINS...
...BUT IF THE FUNCTIONALITY IS CRITICAL TO THE PROJECT, DON’T EVEN ALLOW THE OPTION TO DISABLE.
FURTHER READING• http://codex.wordpress.org/Must_Use_Plugins• http://wpmututorials.com/basics/what-is-the-mu-plugins-folder/
Ronald HuerecaTwitter: @ronalfyFacebook: http://www.facebook.com/ronalfySkype: ronalfySlideshare: http://slideshare.net/ronalfyhttp://www.wpajax.com (WordPress and Ajax - free e-book)http://www.ronalfy.com (Personal website - rants and musings )