LLMS_Forms::is_block_visible_in_list( array $block, array[] $block_list )

Determine if a block is visible in the list it’s contained based on LifterLMS Visibility Settings


Description Description

Fall back on $this->is_block_visible() if empty $block_list is provided.


Top ↑

Parameters Parameters

$block

(array) (Required) Parsed block array.

$block_list

(array[]) (Required) The list of WP Block array $block comes from.


Top ↑

Return Return

(bool) Returns true if $block (and all its parents) are visible. Returns false when $block or any of its parents are hidden or when $block is not found within $block_list.


Top ↑

Source Source

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

	 * @return bool Returns `true` if `$block` (and all its parents) are visible. Returns `false` when `$block`
	 *              or any of its parents are hidden or when `$block` is not found within `$block_list`.
	 */
	public function is_block_visible_in_list( $block, $block_list ) {

		if ( empty( $block_list ) ) {
			return $this->is_block_visible( $block );
		}

		$path       = $this->get_block_path( $block, $block_list );
		$is_visible = ! empty( $path ); // Assume the block is visible until proven hidden, except when path is empty.
		foreach ( $path as $block ) {
			if ( ! $this->is_block_visible( $block ) ) {
				$is_visible = false;
				break;
			}
		}

		/**
		 * Filter whether or not the block is visible in the list of blocks it's contained.
		 *
		 * @since 5.1.0
		 *
		 * @param bool    $is_visible Whether or not the block is visible.
		 * @param array   $block      Parsed block array.
		 * @param array[] $block_list The list of WP Block array `$block` comes from.
		 */


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.