Created
April 1, 2021 10:35
-
-
Save codepuncher/ab99f07630355d690ffc0cec484eb0b0 to your computer and use it in GitHub Desktop.
Revisions
-
codepuncher created this gist
Apr 1, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ <?php /** * Add a "Background Class" setting to the row, advanced, CSS selectors section. */ add_filter('fl_builder_register_settings_form', function (array $form, string $id): array { if ('row' !== $id) { return $form; } $form['tabs']['advanced']['sections']['css_selectors']['fields']['background_class'] = [ 'type' => 'select', 'label' => __('Background Class', 'avado'), 'default' => 'bg-color-default', 'options' => get_background_colours(), ]; return $form; }, 10, 2); /** * Adds the chosen "Background class" to the row. */ add_filter('fl_builder_row_attributes', function (array $attrs, object $row): array { if ('row' !== $row->type) { return $attrs; } if ('bg-color-default' === $row->settings->background_class) { return $attrs; } $attrs['class'][] = $row->settings->background_class; return $attrs; }, 10, 2);