Settings
Last modified:
Blockstudio includes a powerful settings API, that allows setting options via a
blockstudio.json
file inside your theme folder and/or filters. Additionally,
allowed users are able to change the settings visually inside the admin area.
Via
JSON
If a blockstudio.json
file is present inside your theme folder, it will be
used to set the default options for the current site. A JSON
schema is available to validate
the file and help with autocompletion when used in an IDE.
The following properties are available.
{ "$schema": "https://app.blockstudio.dev/schema/blockstudio", "users": { "ids": [], "roles": [] }, "assets": { "enqueue": true, "minify": { "css": false, "js": false }, "process": { "scss": false } }, "editor": { "formatOnSave": false, "assets": [], "markup": false }, "library": false }
Copy
Filters
Alternatively you can use the blockstudio/settings/${setting}
filter to set
options via PHP for more flexibility.
add_filter('blockstudio/settings/assets/enqueue', '__return_false'); add_filter('blockstudio/settings/editor/formatOnSave', '__return_true'); add_filter('blockstudio/settings/library', '__return_true');
Copy
Options set via the blockstudio/settings/${setting}
filter will override the
ones set via the blockstudio.json
file. Both methods can be used together.
Admin
Allowed users from the blockstudio/settings/users/ids
and
blockstudio/settings/users/roles
filters are able to change the settings
visually inside the admin area. If the Save as JSON
checkbox is checked, the
settings will be saved to the JSON file, otherwise they will be saved to the
database into the options
table.
Settings set via filters will be grayed out and disabled inside the admin area.
Settings
Users
Settings related to allowed users with access to the settings and editor.
users/ids
List of user IDs with access to the settings and editor.
add_filter('blockstudio/settings/users/ids', function() { return [1]; });
Copy
users/roles
List of user roles with access to the settings and editor.
add_filter('blockstudio/settings/users/roles', function() { return ["administrator","editor"]; });
Copy
Assets
Settings related to asset management.
assets/enqueue
Enqueue assets in frontend and editor.
add_filter('blockstudio/settings/assets/enqueue', function() { return true; });
Copy
assets/minify/css
Minify CSS.
add_filter('blockstudio/settings/assets/minify/css', function() { return false; });
Copy
assets/minify/js
Minify JS.
add_filter('blockstudio/settings/assets/minify/js', function() { return false; });
Copy
assets/process/scss
Process SCSS to CSS.
add_filter('blockstudio/settings/assets/process/scss', function() { return false; });
Copy
Editor
Settings related to the editor.
editor/formatOnSave
Format code upon saving.
add_filter('blockstudio/settings/editor/formatOnSave', function() { return false; });
Copy
editor/assets
Additional asset IDs to be enqueued.
add_filter('blockstudio/settings/editor/assets', function() { return ["my-stylesheet","another-stylesheet"]; });
Copy
editor/markup
Additional markup to be added to the end of the editor.
add_filter('blockstudio/settings/editor/markup', function() { return '<style>body { background: black; }</style>'; });
Copy
Library
Add block library.
add_filter('blockstudio/settings/library', function() { return false; });
Copy