System Filters
This page documents filters for plugin options, filesystem access, and admin scripts.
| Filter | Description |
|---|---|
unblock/admin/localize_script | Admin JavaScript data |
unblock/defaults/options | Default plugin options |
unblock/filesystem | Filesystem access control |
admin/localize_script
Filter the data passed to the admin JavaScript.
| Parameter | Type | Description |
|---|---|---|
$data | array | Data to be localized for admin scripts |
Example: Add Custom Data
add_filter( 'unblock/admin/localize_script', function ( $data ) {
$data['myPlugin'] = [
'apiUrl' => rest_url( 'my-plugin/v1' ),
'nonce' => wp_create_nonce( 'my-plugin' ),
];
return $data;
} );
defaults/options
Modify default plugin option values before they are merged with saved options.
| Parameter | Type | Description |
|---|---|---|
$defaults | array | Default 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 access the filesystem.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether filesystem is enabled |
Default: true
Example: Disable for Restricted Environments
add_filter( 'unblock/filesystem', function ( $enabled ) {
if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
return false;
}
return $enabled;
} );
Example: Environment-Based Control
add_filter( 'unblock/filesystem', function ( $enabled ) {
// Disable filesystem in production.
if ( wp_get_environment_type() === 'production' ) {
return false;
}
return $enabled;
} );
Next steps
- Data filters — providers, meta, and expression extensions
- Assets filters — CSS inlining threshold