Community程式設計與開發github.com

umairmsm/wp-build

WordPress wp-site-kit 建置的第三階段:在本機 DDEV 站點中建置核心外掛、子佈景主題、內容模型與詢問管道。

wp-build 是什麼?

此技能對應 wp-site-kit WordPress 專案的「Stage 3: Build」,專注於讓網站能在本機環境完整運作。它引導開發者依序完成:透過 DDEV 啟動本地站點、重新命名範例內容類型以符合業務詞彙、使用自訂欄位 (post meta) 建立內容模型、透過 Markdown/JSON 檔案與 WP-CLI 腳本批次匯入資料、在主題範本中僅呼叫核心函數取得資料、建置可儲存並轉發潛在客戶的詢問管道、將政策文字集中於核心函數,以及新增模組時需同步更新測試。技能的最終目標是讓結構測試通過、PHPCS 零錯誤,並由 wp-rules-reviewer 審查差異後按照 Conventional Commits 規範提交。此技能支援在 wp-site-kit 專案中新增或修改功能、範本、內容類型、表單或外掛模組。

相容平台~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. 建立內容模型。 找出簡報所需的所有欄位。將每個欄位註冊為具有 sanitize 回呼與 auth 回呼的 post meta。價格以數字形式儲存於 meta。0 表示「價格請洽詢」,切勿使用「免費」。若編輯者需要更豐富的欄位畫面,可在上方額外安裝 ACF(免費版),但僅能透過核心函數讀取值。
  4. 資料檔案 → 產生器(當業主提供大量項目時執行):
    • 在 docs/data/<類型>/ 中為每個項目保留一個 Markdown 或 JSON 檔案;
    • 撰寫一個可重複執行的 WP-CLI 腳本,從這些檔案建立或更新文章;
    • 為其提供 --dry-run 選項;
    • 使用 ddev wp eval-file - < scripts/<名稱>.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
  • 核心外掛與子佈景主題已啟用;子佈景主題的 Skin 正常載入
  • 真實項目透過核心函數呈現;無寫死的卡片、價格或 slug
  • 詢問:已儲存 → 已寄送電子郵件 → 重試 → 清除;在 Mailpit 中完成端到端測試
  • 結構測試通過;PHPCS 0 個錯誤

禁忌

  • 商業邏輯、WP_Query、價格、pll_* 呼叫或政策文字不可放在佈景主題。
  • 未使用 wp_unslash 加上 sanitize 函數的原始 $_POST 或 $_GET;未使用 esc_* 的輸出。
  • 第三方 API 金鑰或端點不可出現在 HTML 或 JS 中。應由伺服器端轉發。
  • 不可使用原始 wp option update 切換外掛模組。請使用外掛本身的 UI 或 CLI,然後重新檢查所有受影響的頁面。
  • 不可使用未加前綴的函數、選項、勾點、meta 鍵或 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.

相關技能