LLM Prompts

Gutenberg Block Conversion Assistant

Converts Gutenberg block code between different languages and formats.

The method

Use this prompt within ChatGPT’s interface. Paste the code of a Gutenberg block (PHP, JavaScript, or HTML) into the prompt. Specify the target language/format for conversion. Ideal for developers porting blocks or creating variations.

The prompts

Prompt 1
I have the following Gutenberg block code written in PHP:

[PHP Code Here]

Please convert this block to a JavaScript-based block using React components and the `wp.element` API. Provide the full JavaScript code for the block, including registration and necessary imports. Focus on modern ES6+ syntax and ensure compatibility with the latest version of the Gutenberg editor. Clearly document any dependencies or build steps required to utilize the generated JavaScript block.
Prompt 2
I have this Gutenberg block definition in HTML:

[HTML Code Here]

Can you convert it to a dynamic Gutenberg block using PHP? The block should display the same HTML structure and content initially, but it should be updatable via the Gutenberg editor interface. Include all necessary PHP code to register the block, define its attributes, and render the block's content dynamically. Prioritize security best practices when handling user input and ensure the block seamlessly integrates with the WordPress theme.