jpskill.com
🛠️ 開発・MCP コミュニティ

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.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o wp-plugin-development.zip https://jpskill.com/download/17350.zip && unzip -o wp-plugin-development.zip && rm wp-plugin-development.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17350.zip -OutFile "$d\wp-plugin-development.zip"; Expand-Archive "$d\wp-plugin-development.zip" -DestinationPath $d -Force; ri "$d\wp-plugin-development.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して wp-plugin-development.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → wp-plugin-development フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
8

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

WP Plugin Development

どのような時に使うか

このスキルは、以下のようなプラグインの作業に使用します。

  • プラグイン構造の作成またはリファクタリング (bootstrap, includes, namespaces/classes)
  • hooks/actions/filters の追加
  • activation/deactivation/uninstall の動作とマイグレーション
  • 設定ページ/オプション/管理 UI (Settings API) の追加
  • セキュリティ修正 (nonces, capabilities, sanitization/escaping, SQL safety)
  • リリースのパッケージング (build artifacts, readme, assets)

必要なインプット

  • リポジトリのルート + 対象のプラグイン (プラグインのメインファイルへのパスが分かっている場合はそのパス)。
  • このプラグインが動作する場所: シングルサイトかマルチサイトか。該当する場合は WP.com の規約。
  • 対象の WordPress + PHP のバージョン (利用可能な API と $wpdb->prepare() でのプレースホルダーのサポートに影響します)。

手順

0) トリアージとプラグインのエントリーポイントの特定

  1. トリアージの実行:
    • node skills/wp-project-triage/scripts/detect_wp_project.mjs
  2. プラグインヘッダーの検出 (決定論的なスキャン):
    • node skills/wp-plugin-development/scripts/detect_plugins.mjs

これがフルサイトのリポジトリである場合は、コードを変更する前に wp-content/plugins/ または mu-plugins/ の下にある特定のプラグインを選択してください。

1) 予測可能なアーキテクチャに従う

ガイドライン:

  • 単一の bootstrap (ヘッダーを持つメインプラグインファイル) を維持します。
  • ファイルロード時に重い副作用を避けます。フックでロードします。
  • フックを登録するには、専用のローダー/クラスを使用することを推奨します。
  • フロントエンドのオーバーヘッドを減らすために、管理者専用のコードを is_admin() (または管理フック) の背後に保持します。

参照:

  • references/structure.md

2) フックとライフサイクル (activation/deactivation/uninstall)

Activation フックは壊れやすいです。ガードレールに従ってください。

  • activation/deactivation フックをトップレベルで登録します。他のフックの中には登録しないでください。
  • リライトルールは、必要な場合にのみ、CPT/ルールを登録した後にのみフラッシュします。
  • uninstall は明示的かつ安全である必要があります (uninstall.php または register_uninstall_hook)。

参照:

  • references/lifecycle.md

3) 設定と管理 UI (Settings API)

オプションには Settings API を推奨します。

  • register_setting(), add_settings_section(), add_settings_field()
  • sanitize_callback を介してサニタイズします。

参照:

  • references/settings-api.md

4) セキュリティのベースライン (常に)

出荷前に:

  • 入力を早期に検証/サニタイズし、出力を遅れてエスケープします。
  • CSRF を防ぐために nonce を使用し、承認のために capability チェックを行います。
  • $_POST / $_GET を直接信頼することを避け、wp_unslash() と特定のキーを使用します。
  • SQL には $wpdb->prepare() を使用し、文字列連結で SQL を構築することを避けます。

参照:

  • references/security.md

5) データストレージ、cron、マイグレーション (必要な場合)

  • 小さな設定にはオプションを推奨します。カスタムテーブルは必要な場合にのみ使用します。
  • cron タスクの場合は、冪等性を確保し、手動実行パス (WP-CLI または管理画面) を提供します。
  • スキーマの変更の場合は、アップグレードルーチンを記述し、スキーマバージョンを保存します。

参照:

  • references/data-and-cron.md

検証

  • プラグインが致命的なエラー/通知なしにアクティブ化されること。
  • 設定が正しく保存および読み取りされること (capability + nonce が強制されること)。
  • uninstall が意図したデータ (およびそれ以外のデータ) を削除すること。
  • リポジトリの lint/テスト (PHPUnit/PHPCS が存在する場合) と、プラグインがアセットを出荷する場合は JS ビルドステップを実行します。

失敗モード/デバッグ

  • Activation フックが発火しない:
    • フックが正しく登録されていない (メインファイルのスコープにない)、メインファイルのパスが間違っている、またはプラグインがネットワークアクティブ化されている
  • 設定が保存されない:
    • 設定が登録されていない、オプショングループが間違っている、capability が欠落している、nonce の失敗
  • セキュリティの低下:
    • nonce が存在するが capability チェックがない。または、サニタイズされた入力が出力時にエスケープされていない

参照:

  • references/debugging.md

エスカレーション

規範的な詳細については、パターンを発明する前に、Plugin Handbook とセキュリティガイドラインを参照してください。

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。