Layers Plugin Guide: Introduction to Layers Extension Development

Extension Development

Last Updated: for: 1.5.4 Time to Read: 2 minutes

This guide provides an overview of what the strengths and limitations of extensions are, how to go about building one for Layers, and how to add or remove functionality the right way. The result should be a clean, Layers-compatible plugin.

This guide is intended for developers who are looking for guidance in creating a commercial extension for Layers, or those working on projects with custom requirements.

Before moving forward with this tutorial, you should have at least an elementary understanding of writing a WordPress plugin. Jonathan from Tuts+ has written an amazing tutorial on “How to write a WordPress Plugin”. Give it a read.

An extension is a special type of WordPress plugin that extends the functionality of a given theme or plugin framework, such as Layers or WooCommerce.

Most functionality may be added to specific implementations of Layers through existing Layers extensions, or many of the wonderful plugins already available under your Plugins → Add New page, so be sure to check out what is available.

A child theme is limited to affecting the front-end styling and basic functionality of Layers. It should  not be used for introducing content structures such as post types, or features that should be available in spite of the activated child theme, such as Shortcodes and widgets. This is where an extension comes in.

There are a few reasons why you would want to build an extension:

  • If you modify Layers directly, you or your client will not be able to update it without losing the changes
  • Extensions greatly speed up development time and testing and can be easily turned on and off.
  • Your extension is essentially a self-contained set of changes which you are in a better position to track and manage.
  • Extensions can be sold for profit and used in tandem with other extensions or child themes, giving them greater reach and application

The division between themes and plugins in WordPress has been a bit blurry for a long time, as both can introduce new functionality to a WordPress install. In general, you need a Child Theme when you want to re-style a theme without or beyond what the WordPress customizer controls or other plugins allow you to do, when you want to add a bit of code to a specific place (such as a search field in the header) or when you want to add custom page templates.

If you want to add functionality such as post types, widgets, meta fields and so on, you must assess whether you want that functionality to be available to other child themes if your theme is deactivated. In most cases, this answer should be yes, since the extension extends Layers, not your child theme – in which case you should separate out front-end from back-end and segregate any major new functionality into an Extension.

Extensions may also be created to provide changes to existing Layers functionality through hooking, such as adding support for all post types to the Posts widget, or enabling the off-canvas sidebar all the time (as you see with our WooCommerce extension)

In this series you will learn:

  • Benefits of using plugins over child themes for adding functionality to Layers
  • How to structure your extension
  • How to use plugin classes
  • How to add things like shortcodes, custom post types, widget areas and custom HTML snippets through action hooks
  • How to add Layers Builder widgets and customizer controls
  • How to test and submit your extension