Community编程与开发github.com

umairmsm/wp-build

第三阶段:构建 WordPress wp-site-kit 站点 - 本地 DDEV 环境、核心必须用插件(模块)、仅用于展示的子主题与皮肤、内容模型(自定义文章类型、元数据、WP_Query、渲染函数)以及保存线索后再转发的查询管线。在 wp-site-kit 站点上构建或修改功能、模板、内容类型、表单或插件模块时使用。

wp-build 是什么?

该技能(wp-build)是 wp-site-kit 工作流的第三阶段,专注于在本地 DDEV 环境中构建和验证 WordPress 站点。它确保站点运行在本地环境,所有实际内容通过核心函数渲染,查询表单能保存、转发并清理数据。技能覆盖从环境检查、内容类型重命名、内容建模到数据文件生成、模板开发、查询管线及政策文本管理的完整流程。支持通过 WP-CLI 脚本基于数据文件创建内容,并为每个区域使用单一核心函数以保证模板与核心分离。技能适用于 Cursor 或 Claude Code 等 AI 辅助开发工具,通过明确的步骤、门控检查和禁止事项确保代码质量与安全性。最终产出经过结构测试、PHPCS 检查并由 wp-rules-reviewer 审核的提交。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/umairmsm/wp-site-kit/tree/HEAD/skills/wp-build

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

第三阶段:构建

目标:站点在本地运行。实际内容通过核心函数渲染。查询保存、转发后清理。结构测试通过。

首先阅读:项目的 AGENTS.md,然后是 references/architecture.md。

步骤

  1. 本地站点。 按照项目的 README.md 中的“首次运行”部分操作。然后检查: ddev wp eval 'echo wp_get_environment_type();' 必须输出 local。 如果不是,请参阅 references/local-env.md。在输出 local 之前,站点会认为自己是生产环境:可能被搜索引擎索引,也可能向真实客户发送邮件。
  2. 重命名示例内容类型。 在内容存在之前执行此操作。将 <prefix>_offer 替换为业务的词语(tour、service、course):包括 modules/content.php 中的文章类型、重写 slug 和标签,以及函数名(_get_offers、_render_offer_card)、parts/offer-card.php 文件和测试。文章类型名称有 20 个字符限制。
  3. 建模内容。 找到需求中需要的每个字段。将其注册为具有清理回调和认证回调的文章元数据。价格在元数据中为数字。0 表示“价格面议”,永远不是“免费”。如果编辑者需要更丰富的字段界面,可以在其基础上添加 ACF(免费)插件,但仅通过核心函数读取值。
  4. 数据文件 → 生成器(当站点所有者提供大量内容时):
    • 在 docs/data/<type>/ 中为每个项目保留一个 Markdown 或 JSON 文件;
    • 编写一个幂等的 WP-CLI 脚本,根据这些文件创建或更新文章;
    • 提供 --dry-run 选项;
    • 使用 ddev wp eval-file - < scripts/<name>.php 运行该脚本。 文件是可审查的真实数据;数据库是其副本。
  5. 模板为每个区域调用一个核心函数。
    • 布局在主题中:模板、parts/、皮肤覆盖。
    • 数据、查询、价格、政策语句和表单来自核心。
    • 使用 function_exists() 保护每个调用,确保插件缺失时模板不会崩溃。
  6. 查询。 保持管线在 modules/enquiry.php 中(references/forms-and-leads.md)。
    • 同时在三个位置添加字段:表单、处理程序和详情框。
    • 在 wp-config.php 常量中设置收件箱和发件人,绝不在代码中硬编码。
  7. 政策文本(条款、押金、取消):在核心中作为单一函数实现(例如 <prefix>_policy( 'cancellation' ))。模板打印该函数,如果模板硬编码了政策语句,测试会失败。
  8. 新模块? 在 modules/ 中添加一个文件,在引导程序中添加一行 require_once,并在同一提交中更新 tests/structure/core.spec.ts。
  9. 检查和提交。
    • 运行 npm run test:structure 和 npm run lint:php(0 错误)。
    • 要求 wp-rules-reviewer 智能体审查差异。
    • 提交(遵循 Conventional Commits)。

门控(在 SITE_STATUS.md 中勾选)

  • wp_get_environment_type() = local
  • 核心插件和子主题已激活;皮肤已加载
  • 实际内容通过核心函数渲染;没有硬编码的卡片、价格或别名
  • 查询:保存 → 邮件发送 → 重试 → 清理;在 Mailpit 中端到端测试
  • 结构测试通过;PHPCS 0 错误

禁止事项

  • 业务逻辑、WP_Query、价格、pll_* 调用或政策文本在主题中。
  • 未使用 wp_unslash 和清理函数的原始 $_POST 或 $_GET;输出未使用 esc_*。
  • 将第三方 API 密钥或端点放在 HTML 或 JS 中;从服务器端转发。
  • 使用原始 wp option update 切换插件模块;使用插件自身的 UI 或 CLI,然后重新检查其影响的每个页面。
  • 未加前缀的函数、选项、钩子、元数据键或 nonce。

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

umairmsm/wp-content

Stage 4 of a wp-site-kit WordPress build - real copy and photos. Content truth (facts only from the owner), AI drafts and owner approval, claims audits, banned words and fake proof, legal pages, the photo pipeline (dedupe, real-only, EXIF strip, WebP sizes, alt text, AI image register), and recorded content changes. Use for "write the copy", "add photos", "the owner sent new photos", "check for duplicates", "update prices or text on the live site", "legal pages".

umairmsm/wp-design

Stage 2 of a wp-site-kit WordPress build - design direction, a static HTML/CSS prototype with design tokens, owner sign-off with screenshots, self-hosted fonts, and porting the approved look into a swappable WordPress skin. Use for "design the site", "new look", "redesign", "change colours or fonts", "make a new skin", "port the prototype to WordPress".

umairmsm/wp-kickoff

Stage 1 of a wp-site-kit WordPress build. Use when starting a new WordPress website or taking over or rebuilding an existing one - discovery brief, stack decision, creating the project with bin/wp-site-new, locked decisions, private repo and credentials inventory. Triggers - "new WordPress site", "start a client website", "rebuild this site", "take over this WordPress site".

umairmsm/wp-operate

Stage 8 of a wp-site-kit WordPress build and everything after launch - backups with an off-machine copy, restore drills, the disaster-recovery runbook, credentials inventory, update policy, alerts, and working from more than one machine (bridge file, workstation doctor, encrypted state bundle, rescuing unpushed work). Use for "backup", "restore", "move to a new machine/server", "update plugins", "what if the server dies", "work from the cloud box", "set up a second machine".

umairmsm/wp-seo

Stage 5 of a wp-site-kit WordPress build - titles and descriptions, canonical URLs, one schema owner and JSON-LD, sitemaps, robots.txt and llms.txt, AI crawler access, redirects (301 vs 302), legacy URL maps, Search Console, and adding languages one pilot at a time with Polylang (hreflang, .po/.mo strings, native review). Use for "SEO", "schema", "redirect", "old URLs", "translate the site", "add French/Spanish", "hreflang", "canonical".

umairmsm/wp-ship

Stage 7 of a wp-site-kit WordPress build - staging behind Cloudflare Access, server hardening, safe deploys from a commit (scripts/deploy-safe.sh), database content changes, the launch audit, DNS cutover without breaking a running business, and the first week after launch. Use for "deploy", "set up staging", "go live", "launch", "cutover", "move DNS", "harden the server".

umairmsm/wp-site

Start here for any WordPress website built with wp-site-kit, from an empty folder to a live site. Use when someone says "build a WordPress site", "new website for a client", "where are we on the site", "what is next before launch", or asks to continue a site project. Finds the current stage from SITE_STATUS.md, applies the hard rules, and hands over to the right stage skill.

相关技能