FLBuilderModel class handles all database operations and data management for Beaver Builder. It provides methods for creating, retrieving, updating, and deleting layout data.
Overview
TheFLBuilderModel class is defined in classes/class-fl-builder-model.php and is responsible for:
- Layout data storage and retrieval
- Node (row, column, module) management
- Template handling
- Settings management
- Module registration
Class Properties
Row Layouts
Predefined column sizes for each row layout type.
class-fl-builder-model.php:18-28
Module Properties
Registered settings forms for modules, rows, and columns.
Instances of all registered modules.
Module aliases with custom names and settings.
Key Methods
Layout Management
get_layout_data()
Retrieves the layout data for a post.Either
'published' or 'draft'The post ID. Defaults to current post.
save_layout()
Saves the current layout data.Whether to publish the layout (true) or save as draft (false)
Whether to exit the builder after saving
fl_builder_before_save_layout- Fires before layout is savedfl_builder_after_save_layout- Fires after layout is saved
class-fl-builder-model.php (multiple methods)
delete_all_asset_cache()
Deletes all cached CSS and JS files for a post.The post ID. Defaults to current post.
Node Management
get_node()
Retrieves a specific node (row, column, or module) by ID.The unique node ID
delete_node()
Deletes a node and all its children.The node ID to delete
move_node()
Moves a node to a new parent and position.The node ID to move
The new parent node ID
The position in the new parent (0-indexed)
Module Registration
register_module()
Registers a custom module class.The module class name
Module configuration array
fl_builder_register_module - Modify module registration
Settings Management
get_global_settings()
Retrieves the global builder settings.fl_builder_get_global_settings - Modify global settings
save_global_settings()
Saves the global builder settings.Settings array to save
fl_builder_global_settings_saved - Fires after settings are saved
get_enabled_modules()
Retrieves the list of enabled modules.['all'] if all are enabled
Template Methods
get_template_selector()
Retrieves template data for the template selector.apply_template()
Applies a template to the current layout.The template ID or path to .dat file
Whether to append (true) or replace (false) existing content
Layout Data Structure
Layout data is stored as an array of node objects, keyed by node ID:Usage Examples
Get Layout Data
Check if Builder is Enabled
Get All Modules
Clear Cache for Post
Related Classes
FLBuilder
Main builder class with UI and rendering
FLBuilderModule
Base class for module development
Data Model Guide
Learn about the layout data structure
Custom Modules
Create custom modules
Best Practices
Use the provided AJAX methods through FLBuilderAJAX for operations in the builder UI. Direct model methods are for programmatic operations.
Source Code Reference
- File:
classes/class-fl-builder-model.php - Since: Version 1.0
- Version: 2.10.1.1