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_Blocks_Visibility::should_filter_block( array $block )

Determine whether or not a block’s rendering should be modified by block-level visibility settings


Description Description

This method does not determine whether or not the block will be rendered, it only determines whether or not we should check if it should be rendered.

This method is primarily used to ensure that LifterLMS core dynamic blocks (pricing table, course syllabus, etc…) are always displayed to creators when editing content within the block editor. This parses data from a block-renderer WP Core API request.


Top ↑

Parameters Parameters

$block

(array) (Required) Block data array.


Top ↑

Return Return

(boolean) If true, block filters should be checked, other wise they will be skipped.


Top ↑

Source Source

File: libraries/lifterlms-blocks/includes/class-llms-blocks-visibility.php

	private function should_filter_block( $block ) {

		// Always filter unless explicitly told not to.
		$should_filter = true;

		if ( llms_is_rest() ) {

			$context = llms_filter_input( INPUT_GET, 'context' );
			$post_id = llms_filter_input( INPUT_GET, 'post_id', FILTER_SANITIZE_NUMBER_INT );

			// Always render blocks when a valid user is requesting the block in the edit context.
			if ( 'edit' === $context && $post_id && current_user_can( 'edit_post', $post_id ) ) {
				$should_filter = false;
			}
		}

		/**
		 * Filters whether or not a block's rendering should be modified by block-level visibility settings
		 *
		 * This filter does not determine whether or not the block will be rendered, it only determines whether
		 * or not we should check if it should be rendered.
		 *
		 * @since 2.0.0
		 *
		 * @param boolean $should_filter Whether or not to apply visibility filters.
		 * @param array   $block         Block data array.
		 */
		return apply_filters( 'llms_blocks_visibility_should_filter_block', $should_filter, $block );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.3.1 Don't use deprecated FILTER_SANITIZE_STRING.
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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