-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Describe the bug
Somehow, the Background Control is able to save a null value as a color. This breaks PPB because it expects each value to be not-null.
Investe the issue, and determine how to prevent null values from being saved, or adjust the code in the builder to accommodate for the possibility of a null value. See the following areas of code to start off when working:
Template uses the colors here:
post-and-page-builder/includes/template/color.php
Lines 15 to 21 in 48c838e
| <li class='panel-selection custom-color'><i class="fa fa-plus" aria-hidden="true"></i></li> | |
| <# _.each( data.customColors, function ( customColor, index ) { | |
| if ( customColor.includes( 'linear-gradient' ) ) { | |
| return; | |
| } | |
| #> | |
| <li data-type="custom" data-index="{{index}}" data-preset="{{customColor}}" style='background-color:{{customColor}}' class="panel-selection"></li> |
The option is pulled and added to the editor.js here:
| 'saved_colors' => Boldgrid_Editor_Option::get( 'custom_colors', array() ), |
The option is saved here:
post-and-page-builder/includes/builder/class-boldgrid-editor-builder.php
Lines 481 to 491 in d2d83da
| public function save_colors() { | |
| if ( isset( $_REQUEST['boldgrid-custom-colors'] ) ) { | |
| $custom_colors = ! empty( $_REQUEST['boldgrid-custom-colors'] ) ? | |
| sanitize_text_field( wp_unslash( $_REQUEST['boldgrid-custom-colors'] ) ) : ''; | |
| $custom_colors = json_decode( $custom_colors, true ); | |
| $custom_colors = is_array( $custom_colors ) ? $custom_colors : array(); | |
| Boldgrid_Editor_Option::update( 'custom_colors', $custom_colors ); | |
| } | |
| } |
In the new react control, the following code will be useful
This is where the component actually edits the field that is saved on publish:
https://github.com/BoldGrid/boldgrid-panel/blob/707b80a7b0ca1753990aa8863b81138e6638a0d3/src/contexts/background-content/background.effects.tsx#L310-L314