CMDG 02: Add a module to your plugin

To add a module, create a folder in your plugin folder and give it a unique name using lowercase letters and dashes such as my-module.

Important: Module folders and file names must be namespaced with a prefix to avoid conflicts with core modules. For example, if your name is Justin Busa and you would like to create a button module, your module path would be jb-button/jb-button.php, because a non-prefixed button/button.php would be overridden by the core button module. If two modules have the same folder name or slug, even if they are in different plugins, there will be a conflict.

Next, create a PHP file within your module folder and give it the same name, such as my-module.php.

Finally, you will need to configure your module's class so it can be registered with Beaver Builder in the next step. To do so, copy and paste the code below into your module's PHP file.

For more detailed information about the module class, see the Module Property Reference and Module Method Reference sections.

This code block contains a group item in the array, which defines the group in which your module will appear in the Content panel in the Beaver Builder editor.

Note: Rename the class to reflect the name of your module and change out the module info in the construct method.

Once you've configured your module class, you'll need to include it within your plugin. To do so, open your main plugin file and include it as shown in the following example.

Now that you've added a module to your plugin, it's time to move on to the next step to register it with Beaver Builder and create the settings form.

Previous:
1. Create a plugin
Next:
3. Define module settings