WordPress: Simplifying plugins and themes developments

WordPress: Simplifying plugins and themes developments

In conjunction of my previews post, that you can find here, we will see how to simplifying plugins and themes developments using a framework and a template engine.

Developing plugins with Herbert

Herbert is a WordPress plugin framework that provides a structured and standardized approach to building plugins. The framework aims to keep business logic separate from template code, so that back- and frontend developers aren’t tripping over each other. Herbert utilizes Composer to handle the framework’s dependencies. Template code is stored in views, which uses the Twig PHP templating engine.

How to?

The complete guide is available in the official website at the next page:

Theming with Twig And Timber

WordPress is a great platform, and it’s as versatile as a platform can be. Proof of that is that it currently powers more than 23% of the internet as we know it. Historically though that has not always been the case and there’s one thing that made WordPress stand out: Themes.

The WordPress theming industry is pretty large and everyday we see new businesses pop-up, offering their own themes. The choices are practically limitless, and you can find whatever you need.

One of WordPress’s strong points is also -in my opinion- its weakest point. WordPress uses old and deprecated PHP stuff, and a mixing of PHP/HTML for is themes.

Some CMSs in order to address that problem has decided to make things a bit better for their developers and use and MVC approach to separate data and view models, using a real templating language for their templates.

By examples, Drupal and Laravel both work with Symphony, which in turn utilizes the twig templating engine.

Installing Timber

Let's now see how to install Timber using our composer.json file from my previous post. The only things you need to do, is to require the timber-library using the next command line:

1composer require wpackagist-plugin/timber-library

How to?

Without create another post about using Twig into WordPress, I prefer refer to you this great article explaining everything your need to know:

Bonus: Debug bar

The team being Timber plugin has also developed a Debug Bar using the WordPress Debug Bar . Once installed, the Timber Debug Bar gives you access to the current template name, its absolute location on your server and the full contents of the context (array) sent to the template.

To install the Timber Debug Bar, execute the next commands:

1composer require wpackagist-plugin/debug-bar↵composer require wpackagist-plugin/debug-bar-timber

Built with Next.js and Joy-UI, deployed on Vercel.

Designed and coded with ♥ in Montreal with WebStorm.

All text is set in the Nunito typeface.

© 2013-2024 All rights reserved.