block-filter.php
Runtime block restriction
Turns the stored deny list into the allow list WordPress expects.
Tags
Table of Contents
Functions
- jpkcom_allow_blocks_is_exempt() : bool
- Whether the current user is exempt from any restriction.
- jpkcom_allow_blocks_current_role_slugs() : array<string|int, string>
- Role slugs of the current user.
- jpkcom_allow_blocks_all_block_names() : array<string|int, string>
- Every block name this site knows about.
- jpkcom_allow_blocks_filter_allowed() : mixed
- Remove the blocked block types from the allowed list.
Functions
jpkcom_allow_blocks_is_exempt()
Whether the current user is exempt from any restriction.
jpkcom_allow_blocks_is_exempt() : bool
Expressed as a capability rather than a role slug so multisite super admins are covered. Administrators are never restricted.
Tags
Return values
bool —True when no restriction applies.
jpkcom_allow_blocks_current_role_slugs()
Role slugs of the current user.
jpkcom_allow_blocks_current_role_slugs() : array<string|int, string>
Tags
Return values
array<string|int, string> —Role slugs, empty when there is no user.
jpkcom_allow_blocks_all_block_names()
Every block name this site knows about.
jpkcom_allow_blocks_all_block_names(array<string|int, mixed> $settings) : array<string|int, string>
The server-side registry, plus every name mentioned in the settings so a deactivated plugin's blocks are not silently forgotten, plus whatever the extension filter adds.
Blocks registered only in JavaScript are invisible to PHP. Sites using
such blocks can add their names through
jpkcom_allow_blocks_extra_block_names.
Parameters
- $settings : array<string|int, mixed>
-
Validated settings.
Tags
Return values
array<string|int, string> —Unique block names.
jpkcom_allow_blocks_filter_allowed()
Remove the blocked block types from the allowed list.
jpkcom_allow_blocks_filter_allowed(mixed $allowed, mixed $context) : mixed
Returns the incoming value untouched whenever nothing is blocked, so an active but unconfigured plugin has no effect at all. An incoming array is only ever reduced, never extended, so restrictions set by other plugins are respected instead of overwritten.
Parameters
- $allowed : mixed
-
Incoming value: true, false or an array of names.
- $context : mixed
-
The block editor context. Unused.
Tags
Return values
mixed —The allowed block types.