Zemez

Developing Addons for Gutenberg. The Honest First-Hand Experience

Zemez team has been observing Gutenberg editor for a very long time. We were genuinely interested in the product and were waiting for the better moment to create our first product suited for this new WordPress editor.

In the beginning of this summer, Matt Mullenberg finally introduced Gutenberg editor integration to WordPress v.5.0 at WCEU, and that was exactly when we decided that the time has finally come.

Our team hasn’t thought too much about the purpose of our first plugin. Instead, we just took our most popular best-selling JetElements plugin and decided to create a similar addon for Gutenberg, that would introduce the widget blocks for adding more content to Gutenberg-built pages.

As a result, we have created JetGuten, the first addon for Gutenberg editor.

In this article we want to share our experience of creating it, so keep reading to know more about our experience of developing JetGuten addon for Gutenberg.

Hoping it will be of help if you’re just planning to start developing your own products for this page editor.

Developing for Gutenberg: It’s all about JavaScript, not PHP

Even in 2015 Matt Mullenweg told us: “Learn JavaScript. Deeply”.

It was the disclaimer, that showed us in which direction all WordPress developers should move in order to keep pace with times.

And now, when developing the product for Gutenberg editor, we see the truthfulness of this statement.

For one, here is the statistics of usage for different programming languages in JetElements, one of our team’s most popular plugins for Elementor.

Here is the statistics for JetGuten, our new addon for Gutenberg.

In the first version of JetGuten we needed PHP only for creating the classic “wrapper” of the plugin, enabling CSS and JS files and for several implementations of AJAX callbacks.

For everything concerning the appearance and blocks settings we used JavaScript.

Sure, this doesn’t mean that we don’t need PHP at all. The backend will still be there in the more complex blocks, which work with posts, taxonomies, third-party API. However, the most part of the code will be written in JavaScript.

The Departure from some of the old standards for creating WordPress plugins

During the years our team has been working with WordPress, we have used one of the most basic principles of programming – “always separate the logics from the presentation”.

Taking it closer to WordPress, such separation can be divided into two different aspects:

  1. Global – presentation – this is the theme, the logics, the plugins.
  2. Local – there is also the need to separate the presentation and the logics inside the theme and the plugins. For this purpose WordPress have the term “template”.

You can find the separation of templates and the files with the logics in any WordPress theme. The same is true for the plugins. The most popular e-Commerce plugin WooCommerce can easily illustrate this statement.

The “Templates” folder includes the files for presentation.

The “Includes” folder consists of the files mostly with the logics.

You can overwrite the templates of the theme using the Child theme. And the same is true for the templates of the plugins – any well-made plugin (e.g., WooCommerce) can also have some of its templates overwritten both from the theme and from the Child theme.

This gives the freedom to both front-end web developers who create the themes, and to end-users.
They actually have no limits in changing the HTML layout. And the functionality will always remain the same.

This freedom was torn from us in Gutemberg editor – at least, for now. The logics is closely tied to the appearance, and this is why you can’t just overwrite the design from the theme.

Both front-end developers and end-users are limited by using CSS only for changing the appearance of the blocks.

We can’t deny that it’s also a very handy tool. However, in some situations the ability to edit HTML layout of the blocks is extremely needed.

No Limits in Creating Interfaces

From our point of view, one of the most important benefits of Gutenberg is the complete freedom for the developers in creating interfaces for the interaction with the editor.
Well, we’ve a bit exaggerated when mentioned the complete freedom – the developer has at hand 2 main locations for adding his custom interface elements.

The first location is the body of the block inside the editor.

The second one is the side panel with the settings, also called “block inspector”.

You can use any elements for managing the appearance of the content inside these locations. I mean, both the standard ones, that are already included in Gutenberg, and the custom ones.

For one, for Animated Box block we have added a control, which switches the block to the front or back side for more convenient editing, and added it into the toolbar of the block’s body.

Such approach gives the developers so much freedom in managing the interface.

Yes, it might be different from the one used when developing the Jet plugins for Elementor. However, it gives us even more tools.

The Freedom to Introduce Blocks in Editor and to Front-end

If you’d like to compare Gutenberg with any other existing page builder, you’ll find out that it has another great benefit. I’m talking about the opportunity to separate the appearance of the block in the editor and on front-end.

Somewhat similar functionality is available in Elementor, and, frankly speaking, any other old-school page builder initially was representing content in the editor and on front-end differently. There are lots of examples: like Divi, Visual Composer, etc.

However, only Gutenberg gives the developers the full freedom to represent the content on front-end and back-end the way they want and need.

We need to implement two methods for any block in Gutenberg: edit() and save().