Complete the code to register a new block in WordPress.
registerBlockType('my-plugin/my-block', { title: 'My Block', [1]: () => <p>Hello World</p> });
The save function defines how the block content is saved and rendered on the front end.
Complete the code to import the necessary function to register a block.
import { [1] } from '@wordpress/blocks';
registerPlugin with block registration.registerBlockType is the function used to register a new block type in WordPress.
Fix the error in the block's edit function to correctly apply block props.
export function Edit() { const blockProps = [1](); return <p {...blockProps}>Editable content</p>; }useBlockProps is the correct hook to get block properties for the editor.
Fill both blanks to create a block attribute and use it in the save function.
attributes: { content: { type: [1] } }, save: (props) => { return <p>{ [2] }</p>; }The attribute type should be 'string'. The save function uses props.attributes.content to output the content.
Fill all three blanks to register a block with a title, category, and icon.
registerBlockType('my-plugin/my-block', { title: [1], category: [2], icon: [3] });
The title is a string naming the block. The category groups the block in the editor. The icon is a dashicon or icon slug.