← 返回
开发者工具 中文

WordPress WP-CLI Internal API

Build, inspect, and extend WP-CLI command code using the documented stable internal API. Use when the task involves custom WP-CLI commands, package bootstrap...
使用稳定的内部 API 构建、检查和扩展 WP‑CLI 命令代码,适用于自定义 WP‑CLI 命令及包引导等任务。
matthewxmurphy
开发者工具 clawhub v0.5.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 596
下载
💾 59
安装
1
版本
#latest

概述

WordPress WP-CLI Internal API

Use this skill when you are writing WP-CLI itself, not merely operating WordPress through wp.

The official internal API reference exposes a stable surface for command registration, logging, hooks, execution, and output formatting. This skill keeps that stable surface close at hand and gives you a quick command skeleton generator.

Use This Skill For

  • building custom WP-CLI commands
  • reviewing command classes that call WP_CLI::add_command()
  • choosing between WP_CLI::log(), success(), warning(), and error()
  • formatting output with WP_CLI\Utils\format_items()
  • running one WP-CLI command from another with WP_CLI::runcommand()
  • using hooks such as WP_CLI::add_hook() and WP_CLI::do_hook()

Do Not Use This Skill For

  • normal site administration where a stock WP-CLI command already exists
  • REST route implementation or review
  • plugin business logic that has nothing to do with WP-CLI command entrypoints

Workflow

1. Stay On The Stable Surface

Read references/stable-internal-api.md.

Start from the officially documented stable methods instead of undocumented internals.

2. Render A Command Skeleton

Use:

scripts/render-command-skeleton.sh --command acme report --class Acme_Report_Command
scripts/render-command-skeleton.sh --command acme report --class Acme_Report_Command --write /tmp/report-command.php

This gives you a minimal command class that already uses:

  • WP_CLI::add_command()
  • WP_CLI::success()
  • WP_CLI\Utils\get_flag_value()
  • WP_CLI\Utils\format_items()

3. Choose Output And Error Patterns Deliberately

Read references/command-patterns.md.

Default rule:

  • human progress: log() or line()
  • successful completion: success()
  • non-fatal concern: warning()
  • fatal stop: error()

4. Prefer Internal Execution Helpers Over Shelling Out

If a command needs to trigger another WP-CLI command, prefer:

  • WP_CLI::runcommand()
  • WP_CLI::launch_self()

Reach for generic shell execution only when the task is truly outside WP-CLI.

Files

  • scripts/render-command-skeleton.sh: render a minimal custom command class and registration stub
  • references/stable-internal-api.md: grouped stable API surface from the official WP-CLI internal API docs
  • references/command-patterns.md: practical command-authoring patterns and guardrails

版本历史

共 1 个版本

  • v0.5.0 当前
    2026-03-30 08:08 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,215
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,807
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 324,210