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::make_block_visible( array $block, array[] $blocks, int $block_index )

Make a block visible within its list of blocks


Parameters Parameters

$block

(array) (Required) Parsed WP_Block array.

$blocks

(array[]) (Required) Array of parsed WP_Block arrays.

$block_index

(int) (Required) Index of the block within the $blocks list. If the block is in a group, this is the the index of the item's parent.


Top ↑

Return Return

(array[])


Top ↑

Source Source

File: includes/forms/class-llms-forms-dynamic-fields.php

	private function make_block_visible( $block, $blocks, $block_index ) {

		if ( LLMS_Forms::instance()->is_block_visible_in_list( $block, array( $blocks[ $block_index ] ) ) ) {
			return $blocks;
		}

		// If the block has a confirm group, use that.
		$confirm = $this->get_confirm_group( $block['attrs']['id'], array( $blocks[ $block_index ] ) );

		$block_to_add = empty( $confirm ) ? $block : $confirm;

		$replace = true;
		// Insert the visible block before the invisible one if the block is in a group,
		// so to avoid the replacement of the whole group which might contain other required fields.
		// But replace the invisible with the visible if otherwise.
		if ( $block_to_add !== $blocks[ $block_index ] ) {
			$replace = false;
			$this->remove_block( $block_to_add, $blocks );
		}

		// Make the block to add and its children visible.
		$block_to_add = $this->make_all_visible( $block_to_add );

		array_splice( $blocks, $block_index, (int) ( ! empty( $replace ) ), array( $block_to_add ) );

		return $blocks;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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