Integrating plugins in themes

1) Is integrating plugins a common practice?

Not really. Normally you got a theme that offers a base functionality. You then only extend the theme with plugins for special purpose like twitter stuff, event calendars, etc.

Imo it makes sense. I’m currently working on an extremly slim theme that has some plugins (OOP approach) that get delivered as plugins, but are not bundled. These plugins offer template tags for pagination, breadcrumbs, … even the loop with post formats. I like the idea of only offering functionality if the user really wants it. For ex. the comment system is rarely needed if you use WP as a CMS for a buisness homepage, so why should the theme offer this? Another pro for this approach: You just disable the plugin and exchange the template tags with custom stuff if you don’t need it.

Important with this approach is: Don’t place those template tags directly. Use hooks & filters wrapped up in functions, so your theme doesn’t crash because of undefined function calls if you disabled a plugin.

2) What are the implications/complications in regards to auto-updating the theme/plugins?

This is something i’m currently questioning myself. I thought about a massive routine that checks for updates on both the theme and the plugins, but overall: It makes no sense. Imo it’s even better if you just use the builtin update system (or use some custom class if you’re not hosting at the official repo). Why: You only update what really needs to get updated. This saves some time and energy, so i’d even call it the “greener” way to go.

3) What would be the most optimized way of including each plugin without breaking pre-existing functionality?

What exactly is in your case pre-existing functionality?

Function Names

WordPress got around 2.500 functions that get read on a request. So questioning if ( function_exists('whatever') ) is never a good idea. Better use unique names. @Jan Fabry had a good idea: He prefixes all his answer functions over here with wpse and the number of the Q – example: wpse14277_function_name(). A 4 or 5 digit number combined with alphas will likely stay unique. Imagine that you got 50 custom functions in your theme and are questioning them against 2.500 per Request (you can do the math yourself) – that’s not performant.
Edit:
If you just want to know if a plugin is active, then use the is_plugin_active() conditional tag.

Leave a Comment