Code snippets instead of plugins

What do you think about creating a code snippets library instead of simple plugins?

There ara lots of simple functions (set image compression rate, disable login by email address, elementor disable translation, change login logo…) for which there is an unnecessary a complete plugin but a few rows php code is enough.

I use this plugin:

Don’t you thinking about integrating these type of code snippets solution into ClassicPress?

Best regards,
Tibor

3 Likes

I like this as an option. Not sure I want to use it instead of using simple plugins when they check all the ‘should-I-use-this-plugin’ boxes, or as usual when I need a snippet, adding it to my basic ‘better cms’ mu-plugin.

2 Likes

I think it’s a terrible idea.

“In addition to”? Certainly. “Instead of”? Certainly not.

WordPress gained dominance because it was so simple to use. Plugins are a major part of that. The vast majority of WP (and, if it gains ground, CP) users don’t know “code” from “corned beef” (holiday-topical reference). Code Snippets are too complicated for the common user for them to be the default.

If it ain’t broke, don’t fix it.

4 Likes

Although cstibi is right about the challenge raised by too many plugins on a website, I do fully agree with Blaze. We should keep in mind that CP is not meant to become a CMS for developers, but a tool that should be as simple to use as WP.
However, to offer a library of code snippets as an additional option is definitely something worth considering.

5 Likes

The idea has been around and used widely in the WP community for a while. Although it sounds great to just use snippets it can soon turn onto a nightmare when hit a problem and have to debug/troubleshoot the issue.

Where do you start in sifting through the many snippets to go through? With plugin you can just deactivate one by one to get to the bottom of the issue without affecting the site too much.

6 Likes

Actually, developers are involved with the development and implementation of a large percentage of business sites, so developers are an important part of our business focused market. But even though I believe the use of snippets has its place, I would hate to unravel another developer’s snippets.

3 Likes

It’s very common for sites to build their own functionality plugin for this. Short of that, you can already add codesnips to functions.php with the onboard file editor.

5 Likes

I have 2 standard must-use functionality plugins that are customized on almost every site I create. One defines and customizes custom post types, and the other is a ‘better cms’ plugin that modifies various aspects of the admin.

4 Likes

I agree with the need for plugins. Over some complexity, I do not think that code snippets replace plugins.

But I think it is not normal to install more than 10 plugins in order to overcome the shortcomings of the core Wordpress. After that 10 base plugin plus 5-10 business plugins I notice that the admin interface works slower and slower.

My suggestion for a solution - integrated into the core system - to have a plugin like code snippet in which all plus base functionality can be turned on / off by check boxes via the admin interface. You can even call it a fine-tuning menu item.

Yes something like that raygulick’s ‘better cms’ plugin.
Is this a plugin available to anyone raygulick?

The trouble is that everyone’s “fine-tuning” plugin will be different as it’s a personal thing. I also have a small plugin that I put onto every site. It’s just for some small tweaks I like to do to simplify the admin area for clients and hide anything that’s not needed. I’ll probably keep adding to it as I find other features I like, so these things are always going to be a work-in-progress.

Mine is here: https://github.com/simplycomputing/sc-utility

3 Likes

I love the idea of a code snippets library. Apart from anything else, it would help significantly with support queries because so often the answer to such queries is to add a snippet of code. Having a central repository of such snippets means (a) some people will search them first and, perhaps, find the answer to their query without having to ask and (b) those responding to a query can simply link to a snippet instead of having to write it from scratch each time.

I do, however, agree that this should not be in place of a plugins directory. The truth is that plugins and snippets both have their place, and they are useful in different contexts.

As for this comment:

After that 10 base plugin plus 5-10 business plugins I notice that the admin interface works slower and slower.

That is almost certainly not a reflection of the number of plugins being run. I have run sites with over 80 plugins installed and seen hardly any impact on site speed. The issue you are witnessing is due, I suspect, to at least some of those plugins containing code that is not particularly well written.

That’s one problem that ClassicPress inevitably inherits from WordPress. The relative simplicity of creating, making available, and installing plugins makes it easy to use poorly-coded plugins. That is not an issue resolved by turning those plugins into snippets. It can be resolved only by improving the quality of the code used.

6 Likes

1000%

2 Likes

I make heavy use of mu-plugins to manage my sites. It works, but it’s not perfect. I would definitely recommend trying this method of managing code snippets, you just need a file manager program.

I think adding a new kind of plugin library is not quite the right way to think about how to manage snippets. With code managed centrally, someone has to do official releases, and site owners have to manage updates, and now there is a new risk of sites breaking due to snippet updates.

And remember, we still have to build a regular plugin directory first :wink:

Here are a couple of ideas that I think would accomplish the same goal, while being easier to manage in some (not all) ways:

  • Add a “Lightweight” filter to our plugin browser. Plugins could be ranked on this tab based on # of files and overall size (smaller is better), and positive reviews.
  • Add a way to install a plugin as a mu-plugin, whether by default for specific plugins or as an option.

This has been discussed previously on our petitions site. If this is something you’d like to see, go leave your vote there: Issues · ClassicPress/ClassicPress · GitHub

Also, I can’t find a link right now, but I hear WP is considering something similar to let you install new Gutenberg blocks.

2 Likes

I believe it’s called Gutenberg Cloud and has a plugin in the repository: Cloud Blocks – WordPress plugin | WordPress.org

1 Like

@cstibi It’s just been for my own use, and it essentially is just a collection of snippets that I can comment in/out as needed for a particular website. What’s in there stems from my own needs and preferences and way of working. You might find some things useful, but you’d probably modify it quite a bit. DM me on slack and I’ll upload an example for you.

1 Like

On my website, evowebdev.com, I have a collection of snippets (a custom post type) mostly for my own use found under the cleverly named ‘Snippets’ tab. I keep it there because I got tired of googling for answers to the same questions every 5-6 months. Ironically, a couple snippets account for about 35% of my web traffic.

1 Like

I’m not sure if that’s good or bad news for you. :smile:

2 Likes

Yeah, well, it’s not really ‘good’. Just shows that presenting a solution people want a solution for draws some traffic. I sort of gave up blogging several years ago, so that’s not bringing any meaningful traffic.

2 Likes

And this is an area where CP can surpass WP (and, perhaps, monetize).

There’s another thread talking about plug-ins where I suggested a “certified compatible” listing for plugins. Certification would require a fee, but would confer priority listing status and a “certified” badge.

If CP establishes itself as a (or the) “go-to” CMS, then devs looking to make money will pay for (and meet the needs for) certification.

Companies pay a lot to be ISO certified (which says zero about the quality of the product). Michelin stars can make a restaurant owner rich. Umpteen organizations businesses exist for (and make a lot of money from) ranking and certifying products.

WordPress doesn’t do this. The only metrics they give are “number of downloads” and “last updated”.

Create a “CP Certified” program, and you’ve got a major market advantage.

6 Likes