跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

wp-block-development

WordPress block editor code review and Gutenberg block development patterns for WordPress 6.x+. Use when reviewing block code, auditing block.json schema, checking editor components, validating render callbacks, analyzing block attributes, verifying InnerBlocks usage, detecting block validation errors, reviewing Interactivity API directives, or when user mentions "block review", "Gutenberg", "block development", "block editor", "block.json", "useBlockProps", "InnerBlocks", "Interactivity API", "data-wp-bind", "render_callback", "dynamic block", "static block", "block deprecation", "block attributes", "block supports", "@wordpress/scripts", "wp-scripts", "block validation error", "save function", "RichText", "InspectorControls", "BlockControls". Detects issues in block.json schema, React/JSX editor patterns, server-side rendering, attribute handling, and frontend interactions.

jorgerosal · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add jorgerosal/wordpress-skills --skill wp-block-development

技能说明


name: wp-block-development description: WordPress block editor code review and Gutenberg block development patterns for WordPress 6.x+. Use when reviewing block code, auditing block.json schema, checking editor components, validating render callbacks, analyzing block attributes, verifying InnerBlocks usage, detecting block validation errors, reviewing Interactivity API directives, or when user mentions "block review", "Gutenberg", "block development", "block editor", "block.json", "useBlockProps", "InnerBlocks", "Interactivity API", "data-wp-bind", "render_callback", "dynamic block", "static block", "block deprecation", "block attributes", "block supports", "@wordpress/scripts", "wp-scripts", "block validation error", "save function", "RichText", "InspectorControls", "BlockControls". Detects issues in block.json schema, React/JSX editor patterns, server-side rendering, attribute handling, and frontend interactions.

WordPress Block Development Review Skill

Overview

Systematic block development review for WordPress 6.x+ block editor (Gutenberg). Core principle: WordPress blocks follow a dual-architecture pattern—React components for the editor (edit function) and either static HTML (save function) or server-side PHP (render_callback/render file) for the frontend. block.json is the single source of truth. Review validates block.json schema, editor patterns (React/JSX), server-side rendering (PHP), attribute handling, deprecation management, and Interactivity API usage. Report findings grouped by file (PHP and JS/JSX files intermixed by actual path) with line numbers, severity labels (CRITICAL/WARNING/INFO), and BAD/GOOD code pairs.

Note: This skill reviews BOTH PHP and JavaScript/React code. PHP follows WordPress PHP Coding Standards (spaces in parentheses, array() not [], Yoda conditions). JavaScript/JSX follows WordPress JS coding standards (tab indentation, JSDoc comments, camelCase for variables/functions, PascalCase for components).

When to Use

Use when:

  • Block plugin code review (single block, multi-block, or block library)
  • block.json schema validation and field verification
  • Editor component review (edit/save functions, React/JSX patterns)
  • Render callback or render file audit (server-side PHP)
  • InnerBlocks pattern review (nested blocks, template, templateLock)
  • Block deprecation check (save function migrations)
  • Interactivity API directive review (WP 6.5+ frontend interactions)
  • Block attribute schema validation (type, source, selector, default)
  • @wordpress/scripts build configuration check
  • Block validation error investigation
  • useBlockProps, RichText, InspectorControls, BlockControls usage

Don't use for:

  • theme.json configuration (use wp-theme-development when available)
  • General React application review (this is block-editor-specific)
  • WooCommerce block extensions (use wp-woocommerce-dev when available)
  • Security-only audits (use wp-security-review for comprehensive security analysis)
  • Plugin architecture audits (use wp-plugin-development for plugin structure)
  • Performance-only audits (use wp-performance-review)

Code Review Workflow

Follow this seven-step workflow for systematic block reviews:

  1. Identify block type and context

    • Single block plugin → One block.json, simple structure
    • Multi-block plugin → Multiple blocks in src/block-one/, src/block-two/
    • Block library/collection → Published as package, namespacing critical
    • Theme blocks → Registered in functions.php, different loading context
  2. Validate block.json schema (BLK-02, BLK-06, BLK-08, BLK-10)

    • apiVersion must be 3 (WP 6.3+). Flag 1 or 2 as WARNING with upgrade guidance.
    • name must be "namespace/block-name" format (lowercase, letters, numbers, dashes)
    • title, category required
    • attributes: validate type, source, selector, default values. Flag type mismatches.
    • supports: color, spacing, typography, align, anchor, html
    • editorScript, script, viewScript, viewScriptModule: validate "file:./path" format
    • style, editorStyle: validate paths
    • render: "file:./render.php" for dynamic blocks
    • $schema field recommended for validation
  3. Check edit function (BLK-05, BLK-20)

    • useBlockProps() MUST be called and spread on wrapper element
    • Import pattern: @wordpress/* packages (GOOD) vs window.wp.* (BAD - legacy)
    • InspectorControls for sidebar settings, BlockControls for toolbar
    • RichText proper usage (tagName, value, onChange, allowedFormats)
    • InnerBlocks with allowedBlocks and template props
    • useSelect/useDispatch from @wordpress/data (combine selectors in single useSelect call)
    • i18n: all user-facing strings wrapped in __() from @wordpress/i18n with text domain
  4. Check save function or render callback

    • Static blocks: useBlockProps.save() MUST be called, RichText.Content for rich text, InnerBlocks.Content for nested blocks
    • Dynamic blocks: save returns null (or InnerBlocks.Content if nested blocks used - BLK-14 CRITICAL)
    • Save function must be DETERMINISTIC - no random values, no Date.now(), no side effects
    • Render callback/render.php: get_block_wrapper_attributes() for wrapper, escape all output (esc_html, esc_attr, esc_url, wp_kses_post but NOT on $content from InnerBlocks - BLK-21), defined( 'ABSPATH' ) || exit; at top
  5. Scan for CRITICAL patterns

    • Missing apiVersion or using 1/2 instead of 3
    • window.wp.* instead of @wordpress/* imports in JS/JSX
    • save function without useBlockProps.save() (apiVersion 3)
    • render callback using wp_kses_post() on $content parameter (breaks embeds)
    • Dynamic block with InnerBlocks but save returns null (no InnerBlocks.Content)
    • Attribute with source: 'meta' (deprecated - use useEntityProp)
    • Invalid attribute type/source combination
    • Missing register_block_type() call in PHP
  6. Check WARNING patterns

    • block.json missing supports field
    • edit function without use
阅读完整来源 ↗