1. WORDPRESS MUST-USE
PLUGINS
by Ronald Huereca
Presented at WordCamp Norway
January 14th, 2012
2. WHAT IS A MUST-USE PLUGIN?
It’s a plugin that cannot be disabled.
3. 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
4. BENEFITS OF MU-PLUGINS
• Cannot be disabled. Ever. Nunca. Aldri.
• Cannot be edited.
• Easy to drop in.
5. 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.
10. 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' );
?>
11. THE LAST mu-plugins
EXAMPLE
ASSUMES A run-me-always.php
DIRECTORY metronet_tasks
STRUCTURE
LIKE THIS: metronet_tasks.php
12. 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
13. ALL OF THESE PLUGINS CAN
BE WRITTEN AS REGULAR
PLUGINS...
14. ...BUT IF THE FUNCTIONALITY
IS CRITICAL TO THE PROJECT,
DON’T EVEN ALLOW THE
OPTION TO DISABLE.