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_Dynamic_Fields::add_required_block_fields( string[] $fields_to_require, array[] $blocks, string $location )
Add required block fields.
Parameters Parameters
- $fields_to_require
-
(string[]) (Required) Array of field ids to require.
- $blocks
-
(array[]) (Required) Array of parsed WP_Block arrays to add required fields to.
- $location
-
(string) (Required) The request form location ID.
Return Return
(array[])
Source Source
File: includes/forms/class-llms-forms-dynamic-fields.php
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | private function add_required_block_fields( $fields_to_require , $blocks , $location ) { $blocks_to_add = array (); foreach ( $fields_to_require as $field_id => $block_to_add ) { // If a reusable block exists for the field, use it. Otherwise use a dynamically generated block from the template schema. $use_reusable = LLMS_Form_Templates::find_reusable_block( $block_to_add ); $block = LLMS_Form_Templates::get_block( $block_to_add , $location , $use_reusable ); if ( $use_reusable ) { // Load reusable block. $_blocks = LLMS_Forms::instance()->load_reusable_blocks( array ( $block ) ); // The reusable block doesn't contain the needed block, use a dynamically generated block from the template schema. if ( empty ( $_blocks ) || ! $this ->find_block( $field_id , $_blocks ) ) { $_blocks = array ( LLMS_Form_Templates::get_block( $block_to_add , $location , false ) ); } $block = $_blocks [0]; } $blocks_to_add [] = $block ; } // Make blocks to add visible. $blocks_to_add = 'checkout' === $location ? array_map ( array ( $this , 'make_all_visible' ), $blocks_to_add ) : $blocks_to_add ; return array_merge ( $blocks , $blocks_to_add ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.4.1 | Introduced. |