Post Snippets

If you do not have a very elementary website, you will need custom developments. In WordPress, the basic way to achieve this is to put all your customizations in the file « functions.php » of your Theme. For 1 or 2 customizations, it may be OK.

But it is finally a (very) bad way to make developments:

  • It is impossible to activate or deactivate only one development without editing the entire functions.php file
  • if you make errors, your website gets bugged and not reachable
  • After some time, your functions.php become huge, hard to read, what I call a « spaghetti platter »

Any serious developper does not use functions.php. There is a mandatory very nice plugin to make customizations: Post Snippets.

The screen copy below shows the customizations of Les Embobineuses.
You can activate or deactivate customizations
Each customization is perfectly identified

On this Website, you have:

  • a Woocommerce shop with online classes reservations
  • past classes have to be hidden
  • classes have to be sorted by class date and time
  • non virtual products are also sold
  • some of these products need a pdf file to be automatically added to the shopping cart
  • shipping cost are automatically calculated based on weight
  • a large part of shop administration can me made easily from front end, not from the quite geeky back-end
  • And a lot more functions to have an easy to administrate and update online shop associated with a physical shop. For example, stocks are handled in one place, both for online shop and physical shop.

This represent several thousands lines of code. I let you imagine the mess if all this were written in one file!

Moreover, post-snippets editor is very nice, with checking opening and closing ( and {, checking that php syntax is OK, and that there is no basic errors.

And there is more: if an error happens on the front end when you save a snippet, then post-snippet deactivate it immediately, you just have to go back to previous page and check your coding!

Laisser un commentaire