LLMS_Forms::get_field_blocks( array $blocks )
Pull LifterLMS Form Field blocks from an array of parsed WP Blocks.
Description Description
Searches innerBlocks arrays recursively.
Parameters Parameters
- $blocks
-
(array) (Required) Array of WP Block arrays from
parse_blocks()
.
Return Return
(array)
Source Source
File: includes/forms/class-llms-forms.php
public function get_field_blocks( $blocks ) { $fields = array(); foreach ( $blocks as $block ) { if ( ! empty( $block['innerBlocks'] ) ) { $fields = array_merge( $fields, $this->get_field_blocks( $block['innerBlocks'] ) ); } elseif ( false !== strpos( $block['blockName'] ?? '', 'llms/form-field-' ) ) { $fields[] = $block; } elseif ( 'core/html' === $block['blockName'] && ! empty( $block['attrs']['type'] ) ) { $fields[] = $block; } } return $fields; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.9.0 | Pass an empty string to strpos() instead of null . |
5.1.0 | First check block's innerBlock attribute exists when checking for inner blocks. Also made the access visibility public. |
5.0.0 | Introduced. |