Community生产力与协作github.com

wordpress/wp-rest-api

用于构建、扩展或调试 WordPress REST API 端点/路由:register_rest_route、WP_REST_Controller/控制器类、模式/参数验证、permission_callback/认证、响应整形、register_rest_field/register_meta,或通过 show_in_rest 暴露 CPT/分类法。

wp-rest-api 是什么?

该技能专注于 WordPress REST API 的开发和调试,适用于 AI 编码助手(如 Claude Code、Cursor 等)在处理与 WordPress 后端交互时的场景。它涵盖了从注册自定义路由(register_rest_route)、使用控制器类(WP_REST_Controller)、定义请求模式和验证参数,到设置权限回调(permission_callback)和认证机制、对 API 响应进行定制(响应整形),以及通过 register_rest_field 或 register_meta 扩展核心数据模型。此外,技能还支持通过 show_in_rest 参数将自定义文章类型(CPT)和分类法暴露为 REST API 端点。这有助于开发者快速生成符合 WordPress 标准的 API 代码,确保与现有权限系统、数据验证和响应格式兼容,避免常见的实现错误。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/wordpress/agent-skills/tree/main/skills/wp-rest-api

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

wp-rest-api 是做什么的?

用于构建、扩展或调试 WordPress REST API 端点/路由:register_rest_route、WP_REST_Controller/控制器类、模式/参数验证、permission_callback/认证、响应整形、register_rest_field/register_meta,或通过 show_in_rest 暴露自定义文章类型(CPT)/分类法。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

wordpress/blueprint

Use when creating, editing, or reviewing WordPress Playground blueprint JSON files. Triggers on mentions of blueprints, playground configuration, or requests to set up a WordPress demo environment.

wordpress/wordpress-router

Use when the user asks about WordPress codebases (plugins, themes, block themes, Gutenberg blocks, WP core checkouts) and you need to quickly classify the repo and route to the correct workflow/skill (blocks, theme.json, REST API, WP-CLI, performance, security, testing, release packaging).

wordpress/wp-abilities-api

Use when working with the WordPress Abilities API (wp_register_ability, wp_register_ability_category, /wp-json/wp-abilities/v1/*, @wordpress/abilities) including defining abilities, categories, meta, REST exposure, and permissions checks for clients.

wordpress/wp-block-development

Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows.

wordpress/wp-block-themes

Use when developing WordPress block themes: theme.json (global settings/styles), templates and template parts, patterns, style variations, and Site Editor troubleshooting (style hierarchy, overrides, caching).

wordpress/wpds

Use when building UIs leveraging the WordPress Design System (WPDS) and its components, tokens, patterns, etc.

wordpress/wp-interactivity-api

Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration, wp_interactivity_*()) including performance, hydration, and directive behavior.

wordpress/wp-performance

Use when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor via REST headers), database/query optimization, autoloaded options, object caching, cron, HTTP API calls, and safe verification.

wordpress/wp-phpstan

Use when configuring, running, or fixing PHPStan static analysis in WordPress projects (plugins/themes/sites): phpstan.neon setup, baselines, WordPress-specific typing, and handling third-party plugin classes.

wordpress/wp-playground

Use for WordPress Playground workflows: fast disposable WP instances in the browser or locally via @wp-playground/cli (server, run-blueprint, build-snapshot), auto-mounting plugins/themes, switching WP/PHP versions, blueprints, and debugging (Xdebug).

wordpress/wp-plugin-development

Use when developing WordPress plugins: architecture and hooks, activation/deactivation/uninstall, admin UI and Settings API, data storage, cron/tasks, security (nonces/capabilities/sanitization/escaping), and release packaging.

wordpress/wp-project-triage

Use when you need a deterministic inspection of a WordPress repository (plugin/theme/block theme/WP core/Gutenberg/full site) including tooling/tests/version hints, and a structured JSON report to guide workflows and guardrails.

wordpress/wp-wpcli-and-ops

Use when working with WP-CLI (wp) for WordPress operations: safe search-replace, db export/import, plugin/theme/user/content management, cron, cache flushing, multisite, and scripting/automation with wp-cli.yml.

相关技能