WordPress Developers: to use functions.php or a functionality plugin?

WordPress functionality plugin

I first learned of the functionality plugin vs functions.php way of thinking either from a StackOverflow comment while searching for some elusive WP answer or via Dave Clements’s posts: Create Functions Plugin and Putting Things Where They Belong. Not sure it matters, but i like to attribute inspiration.

Anywhoo…

The more i’ve tackled WordPress projects, especially while working in-parallel on a few projects or back-to-back with little time to rest, i’ve come to look for more efficient — faster, really! yet without much risk — ways to do things. And, man, this functionality plugin was mind-blowing, but in a way like, oh, wait, wow, how did we, why did we, do things any different these past years?

The main reason to use a functionality plugin is to make sure all your custom functionality are present regardless of what theme you’re using. There’s no reason to have to duplicate work in each theme’s functions.php file.

Will something break or change when/if themes are switched?

That is the key and sole question i had when deciding to put my functions in functions.php or my own functionality plugin. It’s a simple enough question, but the answer might not work so well, especially if your project is already running. Be sure to test locally and on a staging/sandbox server.

Before you go, something to think about that i found interesting when it comes to functionality plugins.

  • Might want to look into MU Plugins — which (now) stands for “Must Use” plugins. Essentially, you would put your functionality plugin in the /wp-content/mu-plugins directory instead of the typical /wp-content/plugins folder.Why? It’s to ensure that your functionality plugin cannot be deactivated by non-admin users. It doesn’t show up in the normal Plugins page. There are some caveats and warnings, though, that you can read about on the Codex entry for Must Use Plugins.

    *Whispers* The Autoloader is your friend.

Thank you Dave Warfel and Bill Erickson for your Custom Functions and Core Functionality functionality plugins, respectively. I utilized their plugins in addition to the code from the articles linked throughout this as inspiration and guiding posts for my own usage, practices, and eventually my own plugin. This is why i love the coding and open source communities.

Hope you learned something today or at least had your interest piqued regarding a different way to do things.

Cheers

If you found this post useful ...

Buy Me a Coffee logo
Wondering why you keep seeing lower-cased 'i' in my posts? Read -> Why ‘i’ is not capitalized

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of