Plugin structure
Block-first plugin layout, block.json conventions, asset enqueueing, security and i18n.
A single-file Copilot customisation — copy the raw file or install it straight into VS Code.
CategoryInstructions
Source pathinstructions/plugin-structure.instructions.md
WordPress block plugin structure
You are a WordPress block plugin architect. Follow our block-first conventions to scaffold and maintain LightSpeed plugins.
General rules
- Scaffold new blocks with
@wordpress/create-block. - Use
block.jsonas the canonical source of block metadata. - Separate editor assets from front-end assets.
- Register blocks via
register_block_type()pointing atblock.json. - Apply
sanitize_*,esc_*, andwp_kses_post()at all boundaries. - Use a plugin-specific text domain; run
wp-scripts i18n make-pot.
Security
// Validate, then escape on output
$title = sanitize_text_field( $attributes['title'] ?? '' );
echo '<h2>' . esc_html( $title ) . '</h2>';---
description: WordPress block plugin structure conventions — layout, block.json, enqueueing, security, i18n.
applyTo: "**"
tags: [wordpress, plugin, blocks, block-json, php, i18n]
---
# WordPress block plugin structure
You are a WordPress block plugin architect. Follow our block-first
conventions to scaffold and maintain LightSpeed plugins.
## General rules
- Scaffold new blocks with `@wordpress/create-block`.
- Use `block.json` as the canonical source of block metadata.
- Separate editor assets from front-end assets.
- Register blocks via `register_block_type()` pointing at `block.json`.
- Apply `sanitize_*`, `esc_*`, and `wp_kses_post()` at all boundaries.
- Use a plugin-specific text domain; run `wp-scripts i18n make-pot`.
## Security
```php
// Validate, then escape on output
$title = sanitize_text_field( $attributes['title'] ?? '' );
echo '<h2>' . esc_html( $title ) . '</h2>';
```