Redesign WordPress Theme using Tinder Framework with Twig Templates
Plugin Detail:
Name: Hotel Tax
Author: Juan Sebastian Echeverry
Version: 0.1.1
PHP version: 7.1^
Core Classes: Baxtian and HotelTax
Theme Detail:
Name: Europa
Author: Juan Sebastian Echeverry
Version: 0.1.1
PHP version: 7.1^
Core Classes: Baxtian and HotelTax
Mr. Juan Sebastian Echeverry, developer of both Europa theme and Hotel Tax plugin, did a good job
using Timber framework and Twig templates instead of using traditional WordPress developing terms. If
anyone who is not used to PHP or WordPress pattern of coding or thought using PHP directly within
HTML is messy, Timber with Twig gives them a very modernized, modular style of coding which is very
similar to any other frameworks or libraries. This creates an even place for any developer who is not
familiar with WordPress conventions or the style of coding. And they ensure making codes separated to
keep the setup very clean and compact. And Timber is not a new technology. It has been in the
developing world for over a decade. So, all in all, it was a good fit for current situations.
Issues:
But, it was a good decision to use the Timber framework with the Twig template, as WordPress isn’t the
perfect tool for everything or everyone, but there is a huge drawback you can see during development.
One of them is Timber support. By default, Timber does not come up with a WordPress core setup.
WordPress doesn’t recognize Timber or Twig.
Timber words independently with many backend programming languages like PHP, Node, Python, and
so on. When it deals with PHP, it uses Twig as a PHP code generator as Twig is a wonderful template
language. Just like JavaScript template languages, a-la Handlebars, or Moustache. The syntax is very
familiar to work with.
But both Timber and Twig are not accessible on WordPress unless providing a Timber plugin for building
the environment for them to sit on. And WP Timber plugin alone is not capable of running Timber on
WordPress. Because we can’t just mix Timber with WordPress and make a hybrid platform. Just the way,
we can’t cook rice and iron balls together. They work differently.
Timber uses WordPress API to get data and show the data through the Twig template. Though Twig is a
PHP template language, no syntax relates to PHP. Twig has its syntax to generate HTML codes to give a
proper structure to web page/template.
For this reason, we can’t follow the regular WordPress templating process but to adopt the Timber
process.
And here, the thing gets complexity. The developer who built both the theme and the plugin used two
core classes ( Baxtian & HotelTax ) that have all the necessary data, roles, security, and core methods.
And he stores them in his private repo and generates all the essential calls from them without exposing
them. Both the theme and the plugin are running based on those classes. And nobody can use those
classes from outside, but only he does. This is a simple trick to bind clients who are using his services as
they can’t use other developers to modify the core functionality by ignoring him. This is why, after
implementing every possible way, only the Europa theme was compatible with that Hotel Tax plugin.
Solution:
I kept the core setup as it was. I leave the plugin and started working on the theme instead. I cannot but
have to do the following implementations for every new theme which going to use this Hotel Tax plugin
in the future.
To use Timber in my theme setup, I had to replace all the template files which were written following
WordPress recommended way with the Timber framework way. So it was a huge risk of losing old theme
files if they were not stored in a safe place. And the risk would increase if the theme was a premium
theme. So I decided to use a child theme and did my experiment there to the full extent.
I changed every possible template into Timber and applied Twig templates in places of PHP expressions.
Timber follows a completely different convention than WordPress. So it took a while to convert the
whole WordPress theme into a Timber theme.
There was another challenge waiting for me. And it was to integrate the Elementor page builder plugin.
Timber doesn’t support the Elementor plugin, but the theme does, and its template was using Elementor
by default. Elementor and Timber are not compatible with each other because to run Elementor, every
template file needs to have “the_content()” – WP core function to generate content of that page or post
template, but Timber with Twig template, doesn’t have that, instead, they use “post/page.content”, this
syntax. So I had to do some round-up custom coding and keep necessary WP functions along with Twig’s
basic setup so everything was able to run without any issue.





