Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Forms::block_to_field_settings( array $block, array[] $block_list = array() )
Converts a block to settings understandable by llms_form_field()
Parameters Parameters
- $block
-
(array) (Required) A WP Block array.
- $block_list
-
(array[]) (Optional) The list of WP Block array
$block
comes from. Default is empty array.Default value: array()
Return Return
(array)
Source Source
File: includes/forms/class-llms-forms.php
private function block_to_field_settings( $block, $block_list = array() ) { $is_visible = $this->is_block_visible_in_list( $block, $block_list ); /** * Filters whether or not invisible fields should be included * * If the block is not visible (according to LLMS block-level visibility settings) * it will return an empty array (signaling the field to be removed). * * @since 5.1.0 * * @param boolean $filter Whether or not invisible fields should be included. Default is `false`. * @param array $block A WP Block array. * @param array[] $block_list The list of WP Block array `$block` comes from. */ if ( ! $is_visible && apply_filters( 'llms_forms_remove_invisible_field', false, $block, $block_list ) ) { return array(); } $attrs = $this->convert_settings_format( $block['attrs'], 'block' ); // If the field is required and hidden it's impossible for the user to fill it out so it gets marked as optional at runtime. if ( ! empty( $attrs['required'] ) && ! $is_visible ) { $attrs['required'] = false; } /** * Filter an LLMS_Form_Field settings array after conversion from a field block * * @since 5.0.0 * @since 5.1.0 Added `$block_list` param. * * @param array $attrs An array of LLMS_Form_Field settings. * @param array $block A WP Block array. * @param array[] $block_list The list of WP Block array `$block` comes from. */ return apply_filters( 'llms_forms_block_to_field_settings', $attrs, $block, $block_list ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.1.0 | Added logic to remove invisible fields. Added $block_list param. |
5.0.0 | Introduced. |