50% black friday discount: BLACKFRIDAY at checkout

Defaults

It is possible to set global defaults for all blocks registered with Blockstudio using the blockstudio/defaults filter:

add_filter( 'blockstudio/defaults', function () { return array( 'post_types' => array( 'post' ), ); } );

The code above will limit all BS blocks to posts. Setting the post type on individual blocks will override the global setting.

Prefix

It may make sense to prefix all blocks if you already have an existing blocks library in either framework. The blockstudio/prefix filter does exactly that:

add_filter( 'blockstudio/prefix', function () { return 'bs'; } );

The code above would convert the block name from acf/my-block to acf/bs-my-block.

Custom paths

Changing the location of the folder that is going to be searched for blocks might be necessary, for example if you are using a page builder like Oxygen, which disables the theme altogether. Use the blockstudio/path filter to do so:

// Custom path within your theme. add_filter( 'blockstudio/path' , function () { return get_template_directory() . '/blocks'; } ); // Custom path within a plugin. add_filter( 'blockstudio/path' , function () { return plugins_url() . '/my-custom-plugin/blocks'; } );

Check out the minimal starter plugin on GitHub, to see how to register blocks from a plugin.

Multiple instances

If the above options are not enough, it is possible to initiate the Blockstudio\Build class on various folders of your choice:

add_action( 'acf/init', function () { // Blockstudio\Build::init( $folder, $prefix ); Blockstudio\Build::init( get_template_directory() . 'client-blocks', 'client' ); Blockstudio\Build::init( get_template_directory() . 'documentation-blocks', 'documentation' ); } );

Using different prefixes is highly advisable in this case, as it'll make sure that no two block names will be the same.

Excluding folders

Sometimes it makes sense to exclude certain folders from Blockstudio. For example, you could have a place to store all components which are used throughout your blocks.

add_filter( 'blockstudio/exclude', function () { return array( 'components' ); } );

The code above will exclude all files inside folders named components.

Assets

When using assets , Blockstudio automatically enqueues a CSS file named style.css and a JS file named script.js with your block if they are available. Both file names can be changed using following filters:

CSS

add_filter( 'blockstudio/style_name', function () { return 'app.css'; } );

JS

add_filter( 'blockstudio/script_name', function () { return 'app.js'; } );

Please note that this filter also applies to the inline file name.