Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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' ),
'default' => '100',
'units' => array( '%' ),
);
}
return $form;
}
function apply_opacity_to_bb_row_bg_color( $settings, $node ) {
if ( 'row' === $node->type ) {
if ( isset( $settings->connections ) ) {
$connections = (array) $settings->connections;
if ( isset( $connections[ 'bg_color' ] ) && is_object( $connections[ 'bg_color' ] ) ) {
$rgb = implode( ',', FLBuilderColor::hex_to_rgb( $settings->bg_color ) );
$alpha = $settings->bg_opacity / 100;
$settings->bg_color = "rgba($rgb, $alpha)";
}
}
}
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.