wp-block
БесплатноБез исполняемых скриптовНе проверенQuick scaffold for Gutenberg block development with block.json, PHP registration, and React components.
от wpgaurav★ 24 звезды на GitHubОб этом скилле
Skill: WordPress Block Development
Build custom Gutenberg blocks using the WordPress Block API and @wordpress/scripts.
Before Starting
- Load
/CLAUDE/context/wordpress-dev.mdfor standards - Ensure Node.js 20+ and npm installed
- Understand React basics and WordPress data layer
Block Types
Static Block
Renders same content in editor and frontend from saved markup.
Dynamic Block
Renders via PHP callback, content generated server-side.
Interactive Block
Uses @wordpress/interactivity API for frontend interactivity without full React.
Project Setup
Using @wordpress/create-block
# Create new block plugin
npx @wordpress/create-block my-block --namespace gt
# Create dynamic block
npx @wordpress/create-block my-dynamic-block --namespace gt --variant dynamic
# Create interactive block
npx @wordpress/create-block my-interactive-block --namespace gt --template @wordpress/create-block-interactive-template
Manual Setup (for existing plugins)
# Initialize npm
npm init -y
# Install dependencies
npm install @wordpress/scripts --save-dev
# Add to package.json scripts
{
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"packages-update": "wp-scripts packages-update"
}
}
File Structure
my-block/
├── my-block.php # Plugin file / block registration
├── package.json
├── src/
│ ├── block.json # Block metadata
│ ├── index.js # Block registration
│ ├── edit.js # Editor component
│ ├── save.js # Save component
│ ├── style.scss # Frontend + editor styles
│ ├── editor.scss # Editor-only styles
│ └── view.js # Frontend interactivity (optional)
└── build/ # Compiled output (gitignored)
block.json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "gt/my-block",
"version": "1.0.0",
"title": "My Block",
"category": "widgets",
"icon": "smiley",
"description": "A custom block that does something useful.",
"keywords": ["custom", "example"],
"textdomain": "my-block",
"attributes": {
"content": {
"type": "string",
"source": "html",
"selector": "p"
},
"alignment": {
"type": "string",
"default": "left"
},
"backgroundColor": {
"type": "string"
},
"showIcon": {
"type": "boolean",
"default": true
},
"iconSize": {
"type": "number",
"default": 24
}
},
"supports": {
"html": false,
"align": ["wide", "full"],
"anchor": true,
"className": true,
"color": {
"background": true,
"text": true,
"link": true
},
"spacing": {
"margin": true,
"padding": true,
"blockGap": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"example": {
"attributes": {
"content": "Example content for the block preview."
}
},
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"viewScript": "file:./view.js",
"render": "file:./render.php"
}
Block Registration (PHP)
Static Block
<?php
/**
* Plugin Name: My Block
* Description: A custom Gutenberg block.
* Version: 1.0.0
* Author: Gaurav Tiwari
* Text Domain: my-block
*
* @package MyBlock
*/
defined( 'ABSPATH' ) || exit;
/**
* Register block.
*/
function gt_my_block_init() {
register_block_type( __DIR__ . '/build' );
}
add_action( 'init', 'gt_my_block_init' );
Dynamic Block
<?php
/**
* Register dynamic block.
*/
function gt_my_block_init() {
register_block_type(
__DIR__ . '/build',
array(
'render_callback' => 'gt_my_block_render',
)
);
}
add_action( 'init', 'gt_my_block_init' );
/**
* Render callback.
*
* @param array $attributes Block attributes.
* @param string $content Block content.
* @param WP_Block $block Block instance.
* @return string
*/
function gt_my_block_render( $attributes, $content, $block ) {
// Get block wrapper attributes.
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => 'gt-my-block',
)
);
// Build output.
$output = sprintf(
'<div %1$s><p>%2$s</p></div>',
$wrapper_attributes,
esc_html( $attrib
Установить wp-block в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл wp-block?
Quick scaffold for Gutenberg block development with block.json, PHP registration, and React components.
Как установить скилл wp-block?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл wp-block запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic