Access blockProps from render callback
-
I am two days in to make a custom dynamic block with PHP callback. Its basics are working! and now trying to clean up the style and size of the created element.
My callback in PHP returns an iframe. This is the last line of the callback:
return ‘<iframe width=800 height=800 src=”https://example.com/test.html”/>
and it does show the iframe in the view. However I think I need to add all properties that would be added in JS (by {…blockProps}) from the PHP callback to make the rendered block nicely formatted with the rest of content.
How do I do it? Namely, I’d like to return the iframe with proper class names and id and other things in the blockProps.
My registration function looks like this:
function test_dynamic_init() { require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); register_block_type( __DIR__ . '/build', array( 'render_callback' => 'test_dynamic_render_callback' ) ); } add_action( 'init', 'test_dynamic_init');
and not have wp_register_script() call. Is it somehow the reason?
- The topic ‘Access blockProps from render callback’ is closed to new replies.