wordpress-plugin-to-emdash
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePort a WordPress plugin to EmDash
将 WordPress 插件移植到 EmDash
Preserve the plugin's user-visible behavior and data model without translating PHP line by line. WordPress and EmDash divide responsibilities differently, so first decide whether each feature belongs in site schema, Astro code, a sandboxed plugin, or a trusted native plugin.
Load creating-plugins before implementing plugin code. Load building-emdash-site when the port changes collections, seeds, queries, or frontend templates. Those skills define the current APIs; this skill covers migration decisions.
在保留插件用户可见行为和数据模型的同时,不要逐行翻译 PHP。WordPress 和 EmDash 划分职责的方式不同,因此首先要决定每项功能应属于 site schema、Astro 代码、sandboxed plugin,还是 trusted native plugin。
实施 plugin code 前,请加载 creating-plugins。当移植变更涉及 collections、seeds、queries 或 frontend templates 时,请加载 building-emdash-site。这些 skill 定义了当前 API;本 skill 涵盖迁移决策。
Understand the source
了解源插件
Inspect the plugin source, installation behavior, database changes, hooks, REST endpoints, scheduled work, admin screens, shortcodes or blocks, frontend output, permissions, and external services. Identify behavior that users rely on separately from WordPress-specific implementation.
Record:
- required content and configuration data;
- actions that mutate or publish data;
- authorization and trust boundaries;
- background or retry behavior;
- frontend and administrator interactions;
- import, migration, and rollback needs;
- license obligations for copied assets or code.
If the source, expected behavior, or target EmDash environment is missing, report the gap instead of inventing an equivalent.
检查 plugin source、installation behavior、database changes、hooks、REST endpoints、scheduled work、admin screens、shortcodes 或 blocks、frontend output、permissions 和 external services。将用户依赖的行为与 WordPress 特有的实现区分开来。
记录:
- 必需的内容和 configuration data;
- 修改或发布数据的 actions;
- authorization 和 trust boundaries;
- background 或 retry behavior;
- frontend 和 administrator interactions;
- import、migration 和 rollback 需求;
- 对复制 assets 或 code 的 license obligations。
如果缺少 source、expected behavior 或 target EmDash environment,请报告相应缺口,而不是臆造一个等价实现。
Assign each responsibility
分配每项职责
| WordPress responsibility | EmDash destination |
|---|---|
| Custom post type, taxonomy, or metadata | Collection, taxonomy, and fields created through the site schema or seed |
| Site-wide presentation setting | Site setting read by Astro templates |
| Plugin-owned user settings | |
| Plugin-owned cursors, caches, or internal state | Plugin-scoped |
| Plugin-owned queryable records | Declared |
| Content discovery, translation, or publication | Capability-gated |
| Runtime taxonomy or redirect management | |
| Comment administration | |
| WordPress REST endpoint | Declared plugin route with explicit methods, inputs, headers, and response mode |
| Scheduled event | |
| Admin page or form | Block Kit for sandboxed plugins; React only for a trusted native plugin |
| Post editor metabox or saved-entry action | |
| User or author lookup | |
| Outbound HTTP request | |
| Media operation | Separate metadata, byte-read, metadata-write, and upload/delete authorities |
| EmDash content API in Astro site code |
| Shortcode or editor block | Existing Portable Text content where possible; a custom Portable Text block requires a trusted native plugin |
| Raw head markup or scripts | Trusted native |
Do not create collections or taxonomies by reaching into EmDash system tables. Use the public schema, seed, CLI, or admin boundary. Do not use internal REST routes to imitate a sandbox API that does not exist.
Keep authorities separate: reading media metadata does not grant bytes, moderation does not grant deletion, publication policy does not grant publication actions, and content restore does not grant ordinary content reads.
| WordPress 职责 | EmDash 归属位置 |
|---|---|
| Custom post type、taxonomy 或 metadata | 通过 site schema 或 seed 创建的 Collection、taxonomy 和 fields |
| 站点级展示设置 | 由 Astro templates 读取的 Site setting |
| 插件自有的用户设置 | |
| 插件自有的 cursors、caches 或 internal state | 插件范围内的 |
| 插件自有的可查询 records | 声明的 |
| 内容发现、translation 或 publication | 受 capability 限制的 |
| 运行时 taxonomy 或 redirect 管理 | 具备 narrowly scoped read/write capability 的 |
| 评论管理 | |
| WordPress REST endpoint | 声明的 plugin route,并明确指定 methods、inputs、headers 和 response mode |
| 定时事件 | |
| Admin 页面或表单 | sandboxed plugins 使用 Block Kit;React 仅限 trusted native plugin 使用 |
| Post editor metabox 或 saved-entry action | private routes 上的 |
| 用户或作者查询 | 带 |
| 出站 HTTP 请求 | 使用 |
| 媒体操作 | 分别授予 metadata、byte-read、metadata-write 和 upload/delete authorities |
| Astro site code 中的 EmDash content API |
| Shortcode 或 editor block | 尽可能使用现有 Portable Text content;custom Portable Text block 需要 trusted native plugin |
| 原始 head markup 或 scripts | trusted native |
不要通过直接操作 EmDash system tables 来创建 collections 或 taxonomies。请使用 public schema、seed、CLI 或 admin boundary。不要利用 internal REST routes 模拟不存在的 sandbox API。
保持 authorities 相互独立:读取 media metadata 不授予 bytes 权限,moderation 不授予 deletion 权限,publication policy 不授予 publication actions 权限,content restore 不授予普通 content reads 权限。
Choose the plugin format
选择插件格式
Use a sandboxed plugin by default. It supports portable hooks, routes, declared storage, media, network access, MCP tools, and Block Kit admin UI through an install-time trust contract.
Use a trusted native plugin only when the feature requires host-process access, React admin code, Astro rendering components, raw page fragments, or custom Portable Text block definitions. State the extra authority and distribution limitation in the migration plan.
Some WordPress plugins do not need an EmDash plugin. A custom post type plus frontend templates may become only schema, seed data, and Astro pages. Do not add a runtime extension when static site structure covers the behavior.
默认使用 sandboxed plugin。它通过 install-time trust contract 支持 portable hooks、routes、declared storage、media、network access、MCP tools 和 Block Kit admin UI。
仅当功能需要 host-process access、React admin code、Astro rendering components、raw page fragments 或 custom Portable Text block definitions 时,才使用 trusted native plugin。应在 migration plan 中说明额外的 authority 和 distribution limitation。
有些 WordPress 插件并不需要 EmDash plugin。一个 custom post type 加上 frontend templates 可能只需转换为 schema、seed data 和 Astro pages。当 static site structure 已覆盖所需行为时,不要添加 runtime extension。
Plan data movement
规划数据迁移
Describe how existing WordPress data maps before writing runtime code:
- map post IDs, slugs, locales, authors, statuses, revisions, and publication dates;
- preserve relationships between posts, terms, media, and plugin-owned records;
- distinguish a one-time import from data that must continue syncing;
- make imports restartable and define how duplicates are detected;
- keep source identifiers when they are needed for reconciliation or redirects;
- identify content that cannot be represented without a product decision.
Use seed data for a new site's initial schema and sample content. Use an importer or migration path for an existing site's production data; a seed is not a backup or ongoing synchronization mechanism.
在编写 runtime code 前,描述现有 WordPress data 的映射方式:
- 映射 post IDs、slugs、locales、authors、statuses、revisions 和 publication dates;
- 保留 posts、terms、media 与 plugin-owned records 之间的关系;
- 区分一次性 import 与必须持续同步的 data;
- 使 imports 可重新启动,并定义 duplicates 的检测方式;
- 当 reconciliation 或 redirects 需要时保留 source identifiers;
- 标出在没有 product decision 的情况下无法表示的 content。
对于新站点,初始 schema 和示例内容使用 seed data。对于现有站点的 production data,使用 importer 或 migration path;seed 不是 backup,也不是 ongoing synchronization mechanism。
Verify equivalent behavior
验证等价行为
Test through the boundary that users and the runtime exercise:
- schema and imported-data assertions for content-model changes;
- production-boundary plugin tests for sandbox hooks, routes, storage, and permissions;
- browser verification for admin and frontend journeys;
- restart, duplicate-delivery, authorization, and failure cases when the source feature depends on them.
Compare observable behavior, not internal structure. Document intentional differences and any WordPress feature that remains unsupported.
通过用户和 runtime 实际使用的 boundary 进行测试:
- 对 content-model changes 执行 schema 和 imported-data assertions;
- 对 sandbox hooks、routes、storage 和 permissions 执行 production-boundary plugin tests;
- 对 admin 和 frontend journeys 执行 browser verification;
- 当 source feature 依赖这些场景时,测试 restart、duplicate-delivery、authorization 和 failure cases。
比较 observable behavior,而非 internal structure。记录 intentional differences 以及仍不受支持的任何 WordPress feature。
Deliver the port
交付移植成果
Provide:
- a concise inventory of the WordPress behavior and data;
- the responsibility map and sandboxed/native decision;
- the data migration or seed plan;
- the implementation across plugin and site code;
- verification evidence and known gaps;
- attribution and license notices for reused code or assets.
提供:
- WordPress behavior 和 data 的简明 inventory;
- responsibility map 以及 sandboxed/native decision;
- data migration 或 seed plan;
- plugin code 和 site code 中的 implementation;
- verification evidence 和 known gaps;
- 对 reused code 或 assets 的 attribution 和 license notices。