Skip to main content

System Filters

This page documents filters for plugin options, filesystem access, and settings REST permissions.

FilterDescription
unblock/defaults/optionsDefault plugin options
unblock/filesystemFilesystem access control
unblock/settings/can_readRead permission for the settings REST endpoint
unblock/settings/can_writeWrite permission for the settings REST endpoint

defaults/options

Modify default plugin option values before they are merged with saved options.

ParameterTypeDescription
$defaultsarrayDefault options

Example: Set Default Value

add_filter( 'unblock/defaults/options', function( $defaults ) {

$defaults['my_option'] = 'custom_value';

return $defaults;

} );

filesystem

Control whether the plugin can write to the filesystem. Unblock uses WP_Filesystem to generate asset files (CSS, JS) and write debug logs. When disabled, assets are inlined instead and log files are not created.

Disable this on hosting environments that block filesystem writes (e.g., read-only containers, restricted shared hosting).

ParameterTypeDescription
$enabledboolWhether filesystem is enabled

Default: true

Example: Disable on Restricted Hosting

add_filter( 'unblock/filesystem', function( $enabled ) {

if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
return false;
}

return $enabled;

} );

settings/can_read

Filter the read permission for the unblock/v1/settings REST endpoint. The endpoint exposes selectors, variables, and at-rules to the block editor.

ParameterTypeDescription
$allowedboolWhether the current user can read settings
$requestWP_REST_RequestThe REST request

Default: current_user_can( 'edit_posts' ) — calibrated on the minimum capability required to enter the block editor.

You probably don't need this filter

Restricting read access below the default breaks the block editor preview for excluded roles — selectors, variables, and at-rules silently fail to load, and blocks render without their custom styles with no error message.

The public front-end is unaffected: rendering happens server-side from the stored options, not via REST.

This filter is provided for symmetry with can_write and for niche multi-tenant scenarios. In most cases, leave it untouched.

settings/can_write

Filter the write permission for the unblock/v1/settings REST endpoint. Writes mutate the global selectors, variables, and at-rules registries.

ParameterTypeDescription
$allowedboolWhether the current user can write settings
$requestWP_REST_RequestThe REST request

Default: current_user_can( 'manage_options' ) — admin only.

Example: Grant Write Access to Editors

add_filter( 'unblock/settings/can_write', function( $allowed, $request ) {

if ( current_user_can( 'edit_others_posts' ) ) {
return true;
}

return $allowed;

}, 10, 2 );
Editor UI follows the filter

The block editor's management surfaces (selector creation, inline rename, visual style controls, font library, inspector panel, manager modal) are gated client-side via WP's native canUser('update', { kind: 'unblock', name: 'settings' }). That check inspects the REST OPTIONS Allow header, which reflects this filter — so granting write access here automatically reveals the corresponding UI.

Next steps