WordPress WP-CLI Internal API — WordPress WP-命令行工具 Internal API
v0.5.0Build, inspect, and extend WP-命令行工具 command code using the documented stable internal API. Use when the task involves custom WP-命令行工具 commands, package bootstraps, command registration, hooks, 输出 辅助工具s, internal execution 辅助工具s, or PHP code that calls `WP_命令行工具::*` or `WP_命令行工具\\Utils::*`.
运行时依赖
安装命令
点击复制技能文档
WordPress WP-命令行工具 Internal API
Use this 技能 when you are writing WP-命令行工具 itself, not merely operating WordPress through wp.
The official internal API reference exposes a stable surface for command registration, 记录ging, hooks, execution, and 输出 格式化ting. This 技能 keeps that stable surface close at hand and gives you a quick command skeleton 生成器.
Use This 技能 For building custom WP-命令行工具 commands reviewing command classes that call WP_命令行工具::添加_command() choosing between WP_命令行工具::记录(), 成功(), 警告(), and error() 格式化ting 输出 with WP_命令行工具\Utils\格式化_items() 运行ning one WP-命令行工具 command from another with WP_命令行工具::运行command() using hooks such as WP_命令行工具::添加_hook() and WP_命令行工具::do_hook() Do Not Use This 技能 For normal site administration where a stock WP-命令行工具 command already exists REST 路由 implementation or review 插件 business 记录ic that has nothing to do with WP-命令行工具 command entrypoints 工作流
- Stay On The Stable Surface
Read references/stable-internal-API.md.
启动 from the officially documented stable methods instead of undocumented internals.
- Render A Command Skeleton
Use:
scripts/render-command-skeleton.sh --command acme 报告 --class Acme_报告_Command scripts/render-command-skeleton.sh --command acme 报告 --class Acme_报告_Command --write /tmp/报告-command.php
This gives you a minimal command class that already uses:
WP_命令行工具::添加_command() WP_命令行工具::成功() WP_命令行工具\Utils\获取_flag_value() WP_命令行工具\Utils\格式化_items()
- Choose 输出 And Error Patterns Deliberately
Read references/command-patterns.md.
Default rule:
human 进度: 记录() or line() 成功ful completion: 成功() non-fatal concern: 警告() fatal 停止: error()
- Prefer Internal Execution 辅助工具s Over Shelling Out
If a command needs to trigger another WP-命令行工具 command, prefer:
WP_命令行工具::运行command() WP_命令行工具::launch_self()
Reach for generic shell execution only when the task is truly outside WP-命令行工具.
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-命令行工具 internal API docs references/command-patterns.md: practical command-authoring patterns and 防护rAIls