Created
December 28, 2022 10:36
-
-
Save thierrypigot/7690aa275c52a28be8c441f936f1f29f to your computer and use it in GitHub Desktop.
Beaver builder custom module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( class_exists( 'FLBuilderModule' ) ) { | |
class Beaver_Builder_Custom_Module extends FLBuilderModule { | |
public function __construct() { | |
parent::__construct( array( | |
'name' => __( 'Custom Module', 'fl-builder' ), | |
'description' => __( 'A custom Beaver Builder module.', 'fl-builder' ), | |
'category' => __( 'My Custom Modules', 'fl-builder' ), | |
'icon' => 'button.svg', | |
'enabled' => true, | |
)); | |
// register and enqueue your own scripts and styles | |
$this->add_js('my-script', $this->url . 'js/my-script.js', array(), '', true); | |
$this->add_css('my-styles', $this->url . 'css/my-styles.css'); | |
} | |
public function enqueue_scripts() { | |
// enqueue your scripts here | |
wp_enqueue_script( 'my-script' ); | |
} | |
public function enqueue_styles() { | |
// enqueue your styles here | |
wp_enqueue_style( 'my-styles' ); | |
} | |
public function render_module_html() { | |
// your module's html output | |
echo '<div class="custom-module-wrapper">'; | |
echo '<h2>My Custom Module</h2>'; | |
echo '</div>'; | |
} | |
} | |
FLBuilder::register_module('Beaver_Builder_Custom_Module', array( | |
'general' => array( | |
'title' => __( 'General', 'fl-builder' ), | |
'sections' => array( | |
'general' => array( | |
'title' => '', | |
'fields' => array( | |
'text' => array( | |
'type' => 'text', | |
'label' => __( 'Text', 'fl-builder' ), | |
'default' => '', | |
'preview' => array( | |
'type' => 'text', | |
'selector' => '.my-text', | |
) | |
) | |
) | |
) | |
) | |
) | |
)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment