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::get_block_path( array $block, array[] $block_list, int $iterations )
Returns a list of block parents plus the block itself in reverse order
Parameters Parameters
- $block
-
(array) (Required) Parsed block array.
- $block_list
-
(array[]) (Required) The list of WP Block array
$blockcomes from. - $iterations
-
(int) (Required) Stores the number of iterations.
Return Return
(array[]) List of WP_Block arrays or an empty array if $block cannot be found within $block_list.
Source Source
File: includes/forms/class-llms-forms.php
$to_merge = array(); // Inner block equals the path, no need to merge it.
} else {
$path = $this->get_block_path( $block, array( $inner_block ), $iterations + 1 );
}
if ( $path ) {
// First iteration, append first block too.
if ( ! $iterations ) {
$to_merge[] = $_block;
}
// Merge.
return array_merge( $path, $to_merge );
}
}
}
// Block not found in the list.
return array();
}
/**
* Returns a filtered version of `$block_list` containing only the passed `$block` and its parents.
*
* @since 5.1.0
*
* @param array $block Parsed block array.
* @param array[] $block_list The list of WP Block array `$block` comes from.
* @return array[] Filtered version of `$block_list` containing only the passed `$block` and its parents.
* Or an empty array if `$block` cannot be found within `$block_list`.
*/
private function get_block_tree( $block, $block_list ) {
foreach ( $block_list as &$_block ) {
// Found the block.
if ( $block === $_block ) {
return array( $block );
}
if ( ! empty( $_block['innerBlocks'] ) ) {
$tree = $this->get_block_tree( $block, $_block['innerBlocks'] );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 5.1.0 | Introduced. |