返回顶部
w

wordpress-wp-cli-internal-apiWP-CLI内部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 bootstraps, command registration, hooks, output helpers, internal execution helpers, or PHP code that calls `WP_CLI::*` or `WP_CLI\\Utils::*`.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.5.0
安全检测
已通过
334
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

wordpress-wp-cli-internal-api

WordPress WP-CLI 内部 API

当您正在编写 WP-CLI 本身,而不仅仅是通过 wp 操作 WordPress 时,请使用此技能。

官方内部 API 参考为命令注册、日志记录、钩子、执行和输出格式化提供了稳定的接口。此技能让您随时掌握该稳定接口,并为您提供快速命令骨架生成器。

此技能适用于

  • - 构建自定义 WP-CLI 命令
  • 审查调用 WPCLI::addcommand() 的命令类
  • 在 WPCLI::log()、success()、warning() 和 error() 之间进行选择
  • 使用 WPCLI\Utils\formatitems() 格式化输出
  • 使用 WPCLI::runcommand() 从另一个 WP-CLI 命令运行一个命令
  • 使用 WPCLI::addhook() 和 WPCLI::dohook() 等钩子

此技能不适用于

  • - 已有标准 WP-CLI 命令的常规站点管理
  • REST 路由实现或审查
  • 与 WP-CLI 命令入口点无关的插件业务逻辑

工作流程

1. 坚持使用稳定接口

阅读 references/stable-internal-api.md

从官方文档记录的稳定方法开始,而不是未文档化的内部方法。

2. 生成命令骨架

使用:

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

这将为您提供一个已使用以下内容的最小命令类:

  • - WPCLI::addcommand()
  • WPCLI::success()
  • WPCLI\Utils\getflagvalue()
  • WPCLI\Utils\formatitems()

3. 慎重选择输出和错误模式

阅读 references/command-patterns.md

默认规则:

  • - 人类可读的进度:log() 或 line()
  • 成功完成:success()
  • 非致命问题:warning()
  • 致命停止:error()

4. 优先使用内部执行辅助函数而非外部调用

如果命令需要触发另一个 WP-CLI 命令,优先使用:

  • - WPCLI::runcommand()
  • WPCLI::launch_self()

只有当任务确实在 WP-CLI 之外时,才考虑使用通用 shell 执行。

文件

  • - scripts/render-command-skeleton.sh:生成最小自定义命令类和注册存根
  • references/stable-internal-api.md:来自官方 WP-CLI 内部 API 文档的分组稳定 API 接口
  • references/command-patterns.md:实用的命令编写模式和防护措施

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 wordpress-wp-cli-internal-api-1776209039 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 wordpress-wp-cli-internal-api-1776209039 技能

通过命令行安装

skillhub install wordpress-wp-cli-internal-api-1776209039

下载

⬇ 下载 wordpress-wp-cli-internal-api v0.5.0(免费)

文件大小: 5.13 KB | 发布时间: 2026-4-15 13:37

v0.5.0 最新 2026-4-15 13:37
# wordpress-wp-cli-internal-api 0.5.0 - First public release. - Adds guidance and skeleton generation for building custom WP-CLI commands against the stable internal API.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部