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:
Get Custom Control TemplateDownload 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:
Name | Description | Example |
---|---|---|
NAMESPACE | A short single word used in class names to avoid conflicts | my |
CONTROL-NAME | Single-word, no spaces. Dashes allowed | icon-picker |
CONTROL_NAME | Single-word, no spaces. Underscores allowed | icon_picker |
CONTROL_LABEL | Multiple words, can include spaces, visible when selecting a control | Icon Picker |
TEXTDOMAIN | Unique identifier for retrieving translated strings. For the best compatibility with wordpress.org, please use your plugin slug (plugin folder name). eg. lzb-CONTROL-NAME | lzb-icon-picker |
PLUGIN_URL | URL to the GitHub or WordPress repository | |
PLUGIN_TAGS | A comma-separated list of relevant tags used for search results on wordpress.org | |
SHORT_DESCRIPTION | Brief description of the control, no longer than 2 lines | |
EXTENDED_DESCRIPTION | Extended description of the control | |
AUTHOR_NAME | Name or wordpress.org username of the author | |
AUTHOR_URL | URL 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.