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_Form_Templates::prepare_block_attrs( array $block )

Prepares block attributes for a given reusable block


Description Description

This method loads a reusable block from the blocks schema and attempts to locate a user information field for the given field block from the user information fields schema.

The field is matched by the block’s "id" attribute which should match a user information field’s "name" attribute.

When a match is found, the information field data is merged into the block data and the settings are converted from field settings to block attributes.


Top ↑

Parameters Parameters

$block

(array) (Required) A partial WP_Block array used to create a reusable block.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/forms/class-llms-form-templates.php

	private static function prepare_block_attrs( $block ) {

		if ( ! empty( $block['innerBlocks'] ) ) {
			foreach ( $block['innerBlocks'] as &$inner_block ) {
				$inner_block = self::prepare_block_attrs( $inner_block );
			}
		} elseif ( ! empty( $block['attrs']['id'] ) ) {

			// If we find a field, merge the block into the field and convert it to block attributes.
			$field          = llms_get_user_information_field( $block['attrs']['id'] );
			$block['attrs'] = $field ? LLMS_Forms::instance()->convert_settings_to_block_attrs( wp_parse_args( $field, $block['attrs'] ) ) : $block['attrs'];

		}

		return $block;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.