Complete the code to create a reusable block in WordPress.
register_block_type('[1]', array('render_callback' => 'render_my_block'));
The block name must be unique and follow the format 'namespace/block-name'.
Complete the code to enqueue a script for your reusable block.
wp_enqueue_script('[1]', plugins_url('block.js', __FILE__), array('wp-blocks', 'wp-element'));
The handle name should be unique and descriptive for your block's script.
Fix the error in the PHP code to register a reusable block category.
add_filter('block_categories_all', function($categories, $post) { return array_merge($categories, array(array('slug' => '[1]', 'title' => __('Custom Blocks')))); }, 10, 2);
The slug must be lowercase, use hyphens, and no spaces.
Fill both blanks to create a reusable block with attributes and save callback.
register_block_type('my-plugin/my-block', array('attributes' => array('content' => array('type' => '[1]')), 'render_callback' => '[2]'));
The attribute type for content is 'string', and the render callback is the function that outputs the block.
Fill all three blanks to create a reusable block with editor script, style, and save callback.
register_block_type('my-plugin/my-block', array('editor_script' => '[1]', 'style' => '[2]', 'render_callback' => '[3]'));
The editor script and style are handles for enqueued assets, and the render callback is the PHP function to display the block.