r/Wordpress • u/ActuaryZestyclose349 • Aug 01 '26
Replacing WordPress plugins with small reusable custom functions – how far do you take it?
I've been rethinking how I approach WordPress builds, especially when maintaining multiple sites.
Over time, I've inherited quite a few sites where relatively simple functionality was handled by a surprisingly large number of plugins. Some were genuinely necessary, but others existed just to solve one very specific problem.
Lately I've been moving in the opposite direction.
Instead of adding another plugin for every small requirement, I've started building small, focused and reusable functions/modules for things like:
- admin restrictions and role-specific cleanup
- language and ACF helpers
- dynamic content utilities
- image/WebP handling
- small frontend/Breakdance utilities
- analytics and consent integrations
- CPT-specific logic
- various performance and security helpers
The idea isn't to replace established plugins like ACF, SEO or caching solutions. It's more about removing dependencies where a plugin is only being used for 5–10% of what it actually does.
I'm also trying to keep these modules intentionally boring: minimal or no admin UI, no unnecessary database tables, and as little dependency on the page builder as possible.
An interesting side effect is that after building a few sites this way, I'm slowly ending up with my own small library of reusable WordPress functionality. New projects can reuse the same tested pieces instead of installing another plugin to solve the same problem.
Obviously, the trade-off is that you now own the code and its maintenance.
I'm curious how others approach this, especially people maintaining multiple client sites.
At what point do you choose a custom reusable function/module over an existing plugin?
Do you maintain your own internal WordPress toolkit or helper plugin?
And has reducing plugin dependencies actually made your sites easier to maintain long-term, or did you eventually just create your own plugin maintenance problem?
7
u/denisgomesfranco Jack of All Trades Aug 01 '26
I host and give maintenance to about 150 Wordpress websites and 50 Woocommerce stores. I usually try to use the minimum number of plugins as possible but also try to use plugins only when their functionality is really relevant. If it's a larger plugin for which I would only use some specific thing I would try to find another one which combined other useful features. For example: I started using Admin and Site Enhancements which replaced other 5 or 6 plugins I used on all sites. ASE is truly, really useful.
And as for client specific functionality, I used to use code snippets but have moved on to making a kind of 'all in one' plugin for my business combining all the useful features I would add to most of the sites, mostly the Woocommerce stores. I now have a plugin with about 30 functions that were developed from client feedback on those stores. These are mostly functions that help the storeowners in their daily activities. A while ago for example I added a function to download Woocommerce orders as CSV files, with or without the respective products in the orders. Storeowners frequently asked for reports or to use the data for analysis and with this I replaced one plugin I used to export the orders.
So yeah, you should have your own code library, it is really useful and it's being quite useful for me. As for maintenance, I do know how to code in PHP, I have a bit of knowledge about Wordpress' and Woocommerce's internal structure, I have already written plugins and code by hand before the AI era but now I do this mostly with AI help. By saying I know how to code I'm not showing off, I'm saying that with this knowledge of the platform you can better guide AI in achieving the results you want and keep it from doing things in a certain way that could cause problems later on.
28
u/NakanoNoNeko Aug 01 '26
I think the line is not how small the feature is, but who notices when WordPress changes underneath it. A 20-line helper used on 30 sites is already a product, just one with no customers complaining until all 30 break 😅 The copied-snippet drift is the part I hate, so I keep shared code in one versioned plugin with an update path and a few tests around the risky hooks. Fewer plugins is nice, but fewer independently maintained components is the real win.
1
u/BM-1985 Aug 01 '26
Yeah, I have been doing this for years now. I know it's not really the place for some of those functions, but I made a boilerplate starter theme with a lot of those features built in. I use it for small/medium sized websites for small businesses.
Plugins are reserved for the big functions like backups, security, forms, SEO, etc.
1
u/TopSydeWP Aug 01 '26
at my agency we keep a versioned helper plugin that gets deployed across client sites, mostly performance tweaks, security hardening, and ACF utilities. the key is treating it like an actual product with semver and a changelog, otherwise you end up with 40 slightly different versions of the same function. we still use established plugins for heavy lifting (forms, seo, caching) but anything we'd otherwise copy-paste gets added to the helper instead.
1
u/RealBasics Jack of All Trades Aug 01 '26
What u/NakanoNoNeko says: "the line is not how small the feature is, but who notices when WordPress changes underneath it."
You can code Wordpress literally any way you want to if you'll be attached to the project for the lifetime of the site. Or, of course, if it's your own site that no one else will ever need to maintain.
Otherwise, even small code snippets are technical debt waiting to happen.
In my specialty I inherit a lot of older sites and in my experience both single-function plugins and code snippets tend to fall in two categories
Oh, and
The downside of using any plugin, obviously, is that they fail to be updated when the original dev moves on, or even get taken over and/or hijacked.
But the upside, as long as they're carefully chosen and kept up to date, the plugin vendor will maintain the plugin as required. You only have to run updates through the WP interface when new versions are released.
The good news about most of those out-of-date plugins is they've usually been replaced by other, better core features and/or newer plugins. (The genuinely simple ones like you're talking about are actually rarely taken over, they just fade away.)
The downside of using code snippets is that
So, going back to the top, if you're the one who's going to do maintenance for the life of the site you can do whatever you like because you'll always be around to a) fix it after b) finding it. If you can remember where you put it.
Otherwise, especially since I'm not always kept on retainer, I try to stick with plugins.
Final point (ironically): Usually the first thing I do when I inherit a site with lots of "chaff" plugins is assess them to see if they're still necessary or to see a core update or another plugin has made it redundant.
3
u/rafark Aug 01 '26
All of those you described are plugins. The size of the code doesn’t dictate what a plugin is. There are plugins that are one line total of runtime code. Plugins are extensions and your functions are extensions.
My opinion is if you’re a programmer you should totally write your own custom small plugins for small problems. If you are not a programmer I suggest to use existing plugins instead.
1
u/Zorewin Aug 01 '26
I build my own media plugin with custom folders.. drag and drop whole structures including images.. also build my own translation plugin.. lean and mean and not so bloated as wpml
4
u/flashbax77 Aug 01 '26
Are you sure this is more secure?
2
u/Diligent_Plan9630 Aug 01 '26
I've done this for a while using a plugin where I can plop in client-unique functions or my company's oft-used functions. And I haven't had any of them break because I keep them really simple!
2
u/unity100 Aug 01 '26
That's a plugin.
2
u/pimplyteen Aug 01 '26
This is a great approach and it will help a lot with bloat
2
u/Coditive_ Aug 03 '26
Some plugins I see as a must-have, like ACF, SEO, or caching, which you already mentioned.
If you have a "big" plugin that you're using only for one small feature, then it is good to ask yourself if it is really needed. Since this way, it is easy to end up with a lot of plugins.
As for how to approach the reusable code, it depends on the client setup.
For example, one of our clients has a multisite with 30ish sites. In this case, the features are shared via the parent theme, and then each child theme adds what is needed for every single site.
We also have a client that has multiple single-site WordPress pages. In this case, we created a custom plugin that has some "core" features every site uses and some additional ones that only a few needed.
~MS
1
u/MrSoulPC915 Aug 01 '26
Quand ce sont des plugins qui n’impliquent aucun risque sur la sécurité (risque d’élévation de privilèges, base de données, etc.), j’entends par là un code ultra simple, bien écrit et qui n’aura pas besoin d’être mis à jour, alors oui.
1
u/Positive-Ring-5172 Aug 01 '26
If only there was a way to bring in code packages of all sizes into a PHP project to compose your project. Y”know, like a composer.
Sarcasm aside, lack of bona fide composer support is the biggest aspect of Wordpress that sucks.
1
u/Dry_Satisfaction3923 Aug 01 '26
I have done this for years…
First, I noticed early on that every theme/child theme I built needed the same few things, almost entirely identical stuff, like adding GA tracking, removing the emoji script, etc. so years ago I built my own plugin for the agency I’m with and maintain that on a company server from where I can push updates. Then I changed agencies and built it again, but even better.
Both agencies had their unique, niche client base in a specific industry, so tools for client A that I built custom plugins for, would then need similar versions or the same version for client B and client C and so on… some of those I have as branded, updatable plugins that we host ourselves, others I have maintained “starter shells” because while they need a similar concept, it’s something every client treats quite different.
I have, for years now been building up company repos with full plugins and starter shells with basic functionality that is well maintained because we’ve all been burned so frequently by third party decisions.
I also have a Block starter theme. FSE starter theme. Child Theme Starter & plugin starter.
Often a lot of what we need SHOULD just be a child theme function BUT we inherited the site without a child theme.
The sites we build using our own repos and little to no third party code never break, all have incredible SEO, WCAG and PageSpeed ratings and a lot of happy clients. The sites we inherit with tons of third party code that’s always upgrading to sell more units at a low cost, always pushing marketing notices in the admin, always depending on other third party code… nightmare inducing stuff.
1
u/DiligentCake4267 Aug 01 '26
I use a custom functions plugin for various lines of code and tweaks only.
I know I can add it via functions.php but I get annoyed when a theme updates and I have to go back in to change it.
I only use this for super basic things though nothing to complex.
1
u/taicv Developer Aug 01 '26
I create a mu (must use) plugins with options to activate each code block if site needed. Since maintain functions.php across sites is hard part
1
u/ReviewMost4463 Aug 01 '26
Potresti creare mu-plugins che si incorporano direttamente e non vanno nella lista plugin nel backend. Oppure direttamente snippet di codice. O meglio ancora creare un unico plugin a singoli moduli separati attivabili e disattivabili
1
u/otto4242 WordPress.org Tech Guy Aug 01 '26
Yeah, you know what small reusable pieces of code fit really nicely with? A custom plugin. That's what a plugin is.
Make your own custom plugins to hold these snippets. It's so easy, that I wrote a plugin to do it for you: https://wordpress.org/plugins/pluginception/
1
u/Medical-Ask7149 Aug 03 '26
So here’s a secret, everything these plugins do can be achieved in code. Plugins are just easy, so people use those instead.
Also the correct architecture is to use plugins. Plugins for functionality, themes for visualization.
But everything is achievable in code and Wordpress core provides a lot of really good hooks to access that functionality. ACF, for instance, is just a UI slapped on top of the register_post_type() hook. Kind of genius in their part.
The question, when to plugin vs write your own functions, that is up to your ability to code and support what you code going forward. Sure a small admin permission might be easy to code, but who’s going to update that function when Wordpress core changes how the hooks you were using work?
So weigh the pros and the cons.
1
u/hammondish Aug 01 '26
You can also build your own minimalist plugins, but I tend to opt for the functions.php customizations as well. At a certain scale, WP is a lot messier than platforms like Joomla, but since most SEO/marketing firms depend on it, I'm pretty much stuck with using it. If you can keep it scalable and secure, then keep it as clean and organized as possible within reason.
-1
u/BOLVERIN1 Jack of All Trades Aug 01 '26
It is the right approach, I would say. WP plugins frequently try to be too much of everything instead of focusing on one problem per plugin
2
u/[deleted] Aug 01 '26
[removed] — view removed comment