Skip to content

Instantly share code, notes, and snippets.

FLBuilder.addHook( 'didRenderLayoutComplete', function() {
var form = $( '.fl-builder-settings' )
if ( ! form.length || 'post-grid' !== form.data( 'type' ) ) {
return
}
// Posts module form is open and the layout just re-rendered.
} )
@fastlinemedia
fastlinemedia / bb-loop-settings.php
Created November 6, 2019 17:42
Add a custom query option to the Beaver Builder loop settings.
<?php
add_filter( 'fl_builder_render_settings_field', function( $field, $name, $setting ) {
if ( 'data_source' === $name ) {
$field['options']['my_option'] = __( 'My Option' );
}
return $field;
}, 10, 3 );
@fastlinemedia
fastlinemedia / row-bg-opacity.php
Created December 4, 2018 23:35
Restore the legacy row background opacity field for Beaver Builder.
<?php
add_filter( 'fl_builder_register_settings_form', 'add_back_bb_row_bg_opacity', 10, 2 );
add_filter( 'fl_builder_node_settings', 'apply_opacity_to_bb_row_bg_color', 10, 2 );
function add_back_bb_row_bg_opacity( $form, $slug ) {
if ( 'row' === $slug ) {
$form['tabs']['style']['sections']['bg_color']['fields']['bg_opacity'] = array(
'type' => 'unit',
'label' => __( 'Opacity', 'fl-builder' ),
<?php
function filter_bb_layout_data( $nodes ) {
// Loop through the nodes.
foreach ( $nodes as $node_id => $node ) {
// Update row settings.
if ( 'row' === $node->type ) {
<?php
function px_field_distance() {
$field = array(
'type' => 'select',
'label' => __( 'My Label', 'fl-builder' ),
'default' => '0',
'options' => array(
'0' => __( 'Option 1', 'fl-builder' ),
'1' => __( 'Option 2', 'fl-builder' )
@fastlinemedia
fastlinemedia / acf-repeater-shortcodes.html
Created March 27, 2018 00:56
ACF repeater and flexible content shortcodes for Beaver Themer
<!-- Repeater with a nested repeater. -->
[wpbb-acf-repeater name='my_repeater']
<p>[wpbb post:acf type='text' name='sub_field_text']</p>
[wpbb-acf-nested-repeater name='nested_repeater']
<p>[wpbb post:acf type='text' name='nested_sub_field_text']</p>
@fastlinemedia
fastlinemedia / node-field-config-example.php
Last active September 1, 2021 19:41
This is an example of looping over the Beaver Builder node data and pulling the field config for each node. You can then use that config to loop over the node settings and check what type of field the setting is.
<?php
/**
* Get the field config for a node.
*
* @param object $node
* @return array|null
*/
function wpsitesync_get_beaver_builder_fields( $node ) {
if ( 'row' === $node->type ) {
@fastlinemedia
fastlinemedia / disable-html-module-render.php
Created September 19, 2017 16:47
Disable HTML module rendering when in the Beaver Builder UI.
add_filter( 'fl_builder_render_module_content', function( $content, $module ) {
if ( 'html' === $module->settings->type && FLBuilderModel::is_builder_active() ) {
$content = 'HTML rendering disabled in the builder.';
}
return $content;
}, 10, 2 );
@fastlinemedia
fastlinemedia / fl_builder_icon_sets.php
Created July 24, 2017 23:01
Using the fl_builder_icon_sets filter to add custom icon fonts to Beaver Builder
function my_custom_icons( $sets ) {
$path = get_stylesheet_directory() . '/my-custom-icons/';
$url = get_stylesheet_directory_uri() . '/my-custom-icons/';
$data = json_decode( file_get_contents( $path . 'selection.json' ) );
$icons = array();
foreach ( $data->icons as $icon ) {
$prefs = $data->preferences->fontPref;
@fastlinemedia
fastlinemedia / shortcodes_in_html_attrs.php
Created May 30, 2017 23:40
Parses the specified shortcodes in Beaver Builder content that have been placed in HTML attrs as WordPress won't parse those.
add_filter( 'fl_builder_before_render_shortcodes', function( $content ) {
$shortcodes = array( 'field' ); // add other shortcodes here if needed
$pattern = get_shortcode_regex( $shortcodes );
$content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content );
return $content;
} );