Create Custom Control

Lazy Blocks plugin is packed with tons of powerful controls such as text, gallery, and repeater. However, when working on a project, it may be necessary to create a new custom control to save and use your unique data.

To easily get started, we prepared a template plugin with custom control. This plugin contains a simple text control with custom style and attribute. It will be a good starting point for your custom control:

Download this repository and take a look at all files, comments, and readme to better understand it.

You will see placeholders in function names, file names, etc, that you will need to change for your own real names. Use this list of available placeholders to easily find it in code and replace:

NAMESPACEA short single word used in class names to avoid conflictsmy
CONTROL-NAMESingle-word, no spaces. Dashes allowedicon-picker
CONTROL_NAMESingle-word, no spaces. Underscores allowedicon_picker
CONTROL_LABELMultiple words, can include spaces, visible when selecting a controlIcon Picker
TEXTDOMAINUnique identifier for retrieving translated strings. For the best compatibility with, please use your plugin slug (plugin folder name). eg. lzb-CONTROL-NAMElzb-icon-picker
PLUGIN_URLURL to the GitHub or WordPress repository
PLUGIN_TAGSA comma-separated list of relevant tags used for search results on
SHORT_DESCRIPTIONBrief description of the control, no longer than 2 lines
EXTENDED_DESCRIPTIONExtended description of the control
AUTHOR_NAMEName or username of the author
AUTHOR_URLURL to author’s website

When all placeholders have been modified, you should be left with a plugin containing all the logic for a custom control! Before diving into any code, first, copy this plugin into your WordPress plugins folder (wp-content/plugins) and activate it.

Was this page helpful?