I’m making a test case for a dynamic block; what’s the absolute minimum code that I need to register a block? (so I don’t need to run create-block
(granted it takes only takes 5 minutes for me to run, then initialize a git repository, and commit it, if I need to share the test case..) I want some smaller and more svlete?
Can I do something smaller and more svelte than running create-block?
I haven’t been able to find a page that lists the absolute bare minimum.
I know I need to have:
a register_block_type
function in php that’s hooked with init
that includes:
name
(and an array with:
render_callback
, editor_style
and style
(and these 2 might not be necessary?)
- a function for the render_callback
- a function that enqueues the stylesheet(s) for
editor_style
andstyle
(wp_enqu
e.g.
function create_block_test_case() {
register_block_type(
'will/my_test_case_block',
array(
'name' => 'latest block',
'render_callback' => 'my_callback',
'style' => 'my_style'
)
);
}
add_action( 'init', 'create_block_test_case' );
function my_callback() {
return 'hi, world!'
}
$style_css="style-index.css";
wp_register_style(
'my_style',
plugins_url( $style_css, __FILE__ ),
array(),
filemtime( "$dir/$style_css" )
);
What else do I need?
Do I need to also create a block.json even though the block registration is done through php?
(I know for a static block; I’ll need to enqueue an editor_script JS file, but for the sake of this question; I’m just concerned about a dynamic one)