WordPress Code Snippets: Keep them Organized with this Plugin!

Code SnippetsYou love code snippets.

Why wouldn’t you? They’re like mini plugins – all the functionality, none of the bloat. You can cherry pick the key features that you need and keep your site lean and mean.

However, code snippets aren’t perfect. Before long, your functions.php file can start to get rather packed and messy. It can be difficult to remember what snippets you have, and why.

It’s not quite as straightforward as your plugins list, is it? At least you can easily spot a no longer needed plugin and do away with it – it’s not so easy when it comes to code snippets.

But now it can be.

Introducing the Code Snippets Plugin

As the developer rather succinctly puts it, Code Snippets is a easy, clean and simple way to add code snippets to your site. It makes creating and managing code snippets a piece of cake.

You can add new code snippets by pasting them into the code box:

Code Snippets

As you can see from the above screen shot, you can name the snippet, as well as give it a description.

All of the code snippets you add are easily managed in much the same way as you do with plugins:

Code Snippets

If you’re a heavy (or even moderate) user of code snippets, this plugin is a must-have addition to your site.

To be quite honest, I think it would make a lot of sense for this to be added to WordPress by default. Code snippets are widely-used, and perhaps it is about time that a GUI such as that in Code Snippets was developed as part of a future WordPress update.

Download Code Snippets here.

7 Responses

    • Does snippetsapp run the code you wrote automatically on your WP site? :D

      Just to be sure, am I right in thinking that Code Snippets plugin actually runs each snippet of code that you activate instead of just storing them like what @Julien is implying by comparing this plugin to snippetsapp.com?

      • Aww! My bad, I didn’t see the “Manage snippets” screenshot. Still, I don’t understand why someone would manage his code this way instead of manually editing the functions.php!

        • I take it you’ve never seen a functions.php running 1000 lines.. :) I have. It was all custom stuff. And believe me, it’s not fun to read.. Some of the code were commented out since wasn’t used anymore. Hooks all over.

          Of course if you only had 1 or 2 or 3 custom snippets of code, running <50 lines long then yeah, it wouldn't make sense to use a manager for that – read the 2nd to the last paragraph :)

  • functions.php bloat is a real problem, but I don’t think this is a good solution.

    First, writing code in the WordPress dashboard is not really appealing.

    Second, and more important – chances are, like the code in functions.php most code snippets will inevitably consist of functionality bound to the theme. What happens if your client changes their theme, and the WP install has loads of filters and actions which are only relevant to the previous theme? Angry phone calls, that’s what happens.

    I would propose a theme structural redesign instead. In place of 1000 lines functions.php, we should be able to write real OOP themes, something that is nigh impossible right now. Additionally, stuff like bootstrapping custom meta boxes, post types and taxonomies should be moved out of the *theme* altogether. This is stuff that has *nothing* to do with the way the site/blog looks. It makes no sense that changing themes botches access to any custom data that has been created.

    It’s one of the areas that WordPress’ multiple personality disorder really gets to you. On the one hand, it’s a blogging platform so it makes sense to not bind the install to any given theme. On the other hand, it’s a CMS and it’s impossible to make due with posts and pages. Custom post types or meta boxes are bound to the theme by being bootstrapped through functions.php, but the actual data is obviously tied to the WP instance. I think in most cases you would want to preserve that data and its structure even if you want to change the look of the site.

    • “I think in most cases you would want to preserve that data and its structure even if you want to change the look of the site.”

      @Rummelhoff funny how you could mention that when in fact this is what this plugin is doing ;)

      also, I don’t think we’re not supposed to “develop” a wp theme/site with this plugin.. that would be stupid.. theme specific functions should go with the theme package.

      but this plugin is pretty useful if you have “snippets” of code that you use regardless of the theme..

      when you come to think of it, Code Snippets is actually a sort of “plugin” manager in itself where instead of writing your own plugin for that 5 lines of code that you use over and over again, you save it as a snippet..

Comments are closed.