Prototype:register_block_type( string|WP_Block_Type $block_type, array $args = array() ): WP_Block_Type|false
add_action( 'init', 'dev__register_blocks', 5 );
function dev__register_blocks() {
register_block_type( __DIR__ . '/some_block_dir' );
}
The block.json file :
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "namespace/blockname",
"title": "Notice",
"category": "text",
"parent": [ "core/group" ],
"icon": "star",
"description": "Shows warning, error or success notices...",
"keywords": [ "alert", "message" ],
"version": "1.0.3",
"textdomain": "my-plugin",
"editorScript": "file:./index.js",
"script": "file:./script.js",
"viewScript": [ "file:./view.js", "example-shared-view-script" ],
"editorStyle": "file:./index.css",
"style": [ "file:./style.css", "example-shared-style" ],
"render": "file:./render.php",
"supports": {
"className": true,
"customClassName": true,
"jsx": true // to use innerBlocks,
"inserter": true // will be accessible only programatically
},
// ACF options:
"acf": {
"mode": "preview",
"renderTemplate": "render.php"
},
"example": { "attributes": { "mode": "preview" } }
}
Sources:
- https://developer.wordpress.org/reference/functions/register_block_type/
- https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/
- https://www.advancedcustomfields.com/resources/acf-blocks-with-block-json/#acf-configuration-key
- https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/