AGENT SKILL

WordPress插件开发

wp-plugin-development

开发 WordPress 插件时使用:架构与钩子、激活/停用/卸载、管理界面与 Settings API、数据存储、定时任务、安全(nonce/权限/清理/转义)以及发布打包。

License 许可
GPL-2.0
所属仓库
gambitph/Cimo
最近更新
2026-10-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
wp-plugin-development
description
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.
compatibility
Targets WordPress 7.0+ (PHP 7.4.0+). Filesystem-based agent with bash + node. Some workflows require WP-CLI.

02 资源文件 7

03 SKILL.md 正文

WP Plugin Development

When to use

Use this skill for plugin work such as:

  • creating or refactoring plugin structure (bootstrap, includes, namespaces/classes)
  • adding hooks/actions/filters
  • activation/deactivation/uninstall behavior and migrations
  • adding settings pages / options / admin UI (Settings API)
  • security fixes (nonces, capabilities, sanitization/escaping, SQL safety)
  • packaging a release (build artifacts, readme, assets)

Inputs required

  • Repo root + target plugin(s) (path to plugin main file if known).
  • Where this plugin runs: single site vs multisite; WP.com conventions if applicable.
  • Target WordPress + PHP versions (affects available APIs and placeholder support in $wpdb->prepare()).

Procedure

0) Triage and locate plugin entrypoints

  1. Run triage:
    • node skills/wp-project-triage/scripts/detect_wp_project.mjs
  2. Detect plugin headers (deterministic scan):
    • node skills/wp-plugin-development/scripts/detect_plugins.mjs

If this is a full site repo, pick the specific plugin under wp-content/plugins/ or mu-plugins/ before changing code.

1) Follow a predictable architecture

Guidelines:

  • Keep a single bootstrap (main plugin file with header).
  • Avoid heavy side effects at file load time; load on hooks.
  • Prefer a dedicated loader/class to register hooks.
  • Keep admin-only code behind is_admin() (or admin hooks) to reduce frontend overhead.

See:

  • references/structure.md

2) Hooks and lifecycle (activation/deactivation/uninstall)

Activation hooks are fragile; follow guardrails:

  • register activation/deactivation hooks at top-level, not inside other hooks
  • flush rewrite rules only when needed and only after registering CPTs/rules
  • uninstall should be explicit and safe (uninstall.php or register_uninstall_hook)

See:

  • references/lifecycle.md

3) Settings and admin UI (Settings API)

Prefer Settings API for options:

  • register_setting(), add_settings_section(), add_settings_field()
  • sanitize via sanitize_callback

See:

  • references/settings-api.md

4) Security baseline (always)

Before shipping:

  • Validate/sanitize input early; escape output late.
  • Use nonces to prevent CSRF and capability checks for authorization.
  • Avoid directly trusting $_POST / $_GET; use wp_unslash() and specific keys.
  • Use $wpdb->prepare() for SQL; avoid building SQL with string concatenation.

See:

  • references/security.md

5) Data storage, cron, migrations (if needed)

  • Prefer options for small config; custom tables only if necessary.
  • For cron tasks, ensure idempotency and provide manual run paths (WP-CLI or admin).
  • For schema changes, write upgrade routines and store schema version.

See:

  • references/data-and-cron.md

Verification

  • Plugin activates with no fatals/notices.
  • Settings save and read correctly (capability + nonce enforced).
  • Uninstall removes intended data (and nothing else).
  • Run repo lint/tests (PHPUnit/PHPCS if present) and any JS build steps if the plugin ships assets.

Failure modes / debugging

  • Activation hook not firing:
    • hook registered incorrectly (not in main file scope), wrong main file path, or plugin is network-activated
  • Settings not saving:
    • settings not registered, wrong option group, missing capability, nonce failure
  • Security regressions:
    • nonce present but missing capability checks; or sanitized input not escaped on output

See:

  • references/debugging.md

Escalation

For canonical detail, consult the Plugin Handbook and security guidelines before inventing patterns.

04 同仓库更多 Skills

gambitph
gambitph/Cimo

智能体技能文档编写

writing-for-agents

为智能体编写文档。在创建或编辑技能(skills),或修改 AGENTS.md 或 CLAUDE.md 时使用。

AI 工程师智能体开发
★ 2
gambitph
gambitph/Cimo

WordPress REST API 开发

wp-rest-api

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

软件开发工程师内容管理系统开发
★ 2
gambitph
gambitph/Cimo

WordPress 项目诊断

wp-project-triage

当你需要对 WordPress 仓库(插件/主题/区块主题/WP 核心/Gutenberg/完整站点)进行确定性检查,包括工具链/测试/版本提示,并生成结构化 JSON 报告以指导工作流和防护栏时使用。

软件开发工程师内容管理系统开发
★ 2
gambitph
gambitph/Cimo

WordPress插件目录合规审查

wp-plugin-directory-guidelines

审查 WordPress 插件的 GPL 合规性、检查许可证头或兼容性、评估追加销售/免费增值/试用版(upsell/freemium/trialware)模式、验证插件命名或商标规则、检查插件 slug、理解某个插件为何被 WordPress.org 拒绝,或回答有关 18 条 WordPress.org 插件目录指南的任何问题——即使用户没有明确提到『指南』。

质量合规审核员开源许可证合规审计
★ 2
gambitph
gambitph/Cimo

WordPress 性能剖析与优化

wp-performance

在排查或改进 WordPress 性能时使用(仅限后端代理):性能剖析与测量(WP-CLI profile/doctor、Server-Timing、通过 REST 请求头使用 Query Monitor)、数据库/查询优化、自动加载选项(autoloaded options)、对象缓存、定时任务(cron)、HTTP API 调用,以及安全验证。

软件开发工程师性能剖析与优化
★ 2
gambitph
gambitph/Cimo

WordPress 区块图案生成

wp-patterns

生成技术上正确、设计上独具特色的 WordPress 区块图案(block patterns)。在创建区块图案、起始页面图案、模板图案、模板部件图案,或改进图案设计质量时使用。涵盖图案注册(PHP 文件头、自动/手动)、区块标记语法、theme.json 设计令牌、分类、模板类型、无障碍访问,以及国际化(i18n)/转义。

软件开发工程师内容管理系统开发
★ 2