How can I add a custom module for Divi Wordpress theme? http://www.elegantthemes.com/gallery/divi/
Original modules are created in main-modules.php
Example:
class ET_Builder_Module_Gallery extends ET_Builder_Module { .... }
But the ET_Builder_Module
class is not accessible in my plugin, or in theme functions.php
Important note: The slug for your custom module must contain the string
et_pb_
, or it will be filtered out by the functionet_pb_allowed_modules_list()
.I was able to add a new Divi module using the following code (requires PHP 5.3+ for the anonymous function):
Inside the included file, copy and paste a
class
from thewp-content/themes/Divi/includes/builder/main-modules.php
file, then modify to suit your needs. See the example below (copy an actual class from the file mentioned to get the content of each method listed below… I like theET_Builder_Module_Code
class for simplicity's sake):