wordpress-plugin-to-emdash

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Port 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 responsibilityEmDash destination
Custom post type, taxonomy, or metadataCollection, taxonomy, and fields created through the site schema or seed
Site-wide presentation settingSite setting read by Astro templates
Plugin-owned user settings
ctx.settings
; declare credentials as encrypted
secret
fields
Plugin-owned cursors, caches, or internal statePlugin-scoped
ctx.kv
Plugin-owned queryable recordsDeclared
ctx.storage.<collection>
storage
Content discovery, translation, or publicationCapability-gated
ctx.content
and
ctx.schema
; policy hooks and actions have separate authority
Runtime taxonomy or redirect management
ctx.taxonomies
or
ctx.redirects
with narrow read/write capability
Comment administration
ctx.comments
; reads expose personal data and moderation uses expected status
WordPress REST endpointDeclared plugin route with explicit methods, inputs, headers, and response mode
Scheduled event
cron
hook and
ctx.cron
scheduling
Admin page or formBlock Kit for sandboxed plugins; React only for a trusted native plugin
Post editor metabox or saved-entry action
admin.editorPanels
or
admin.editorActions
on private routes
User or author lookup
ctx.users
with
users:read
Outbound HTTP request
ctx.http.fetch()
with
network:request
and an
allowedHosts
entry
Media operationSeparate metadata, byte-read, metadata-write, and upload/delete authorities
WP_Query
or template tag
EmDash content API in Astro site code
Shortcode or editor blockExisting Portable Text content where possible; a custom Portable Text block requires a trusted native plugin
Raw head markup or scriptsTrusted native
page:fragments
; registry-installed plugins can contribute validated
page:metadata
only
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
插件自有的用户设置
ctx.settings
;将 credentials 声明为加密的
secret
fields
插件自有的 cursors、caches 或 internal state插件范围内的
ctx.kv
插件自有的可查询 records声明的
ctx.storage.<collection>
storage
内容发现、translation 或 publication受 capability 限制的
ctx.content
和
ctx.schema
;policy hooks 和 actions 具有独立 authority
运行时 taxonomy 或 redirect 管理具备 narrowly scoped read/write capability 的
ctx.taxonomies
或
ctx.redirects
评论管理
ctx.comments
;reads 会暴露 personal data,moderation 使用预期 status
WordPress REST endpoint声明的 plugin route,并明确指定 methods、inputs、headers 和 response mode
定时事件
cron
hook 和
ctx.cron
scheduling
Admin 页面或表单sandboxed plugins 使用 Block Kit;React 仅限 trusted native plugin 使用
Post editor metabox 或 saved-entry actionprivate routes 上的
admin.editorPanels
或
admin.editorActions
用户或作者查询带
users:read
的
ctx.users
出站 HTTP 请求使用
ctx.http.fetch()
,并配置
network:request
和一个
allowedHosts
entry
媒体操作分别授予 metadata、byte-read、metadata-write 和 upload/delete authorities
WP_Query
或 template tag
Astro site code 中的 EmDash content API
Shortcode 或 editor block尽可能使用现有 Portable Text content;custom Portable Text block 需要 trusted native plugin
原始 head markup 或 scriptstrusted native
page:fragments
;registry-installed plugins 只能提供经过验证的
page:metadata
不要通过直接操作 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:
  1. a concise inventory of the WordPress behavior and data;
  2. the responsibility map and sandboxed/native decision;
  3. the data migration or seed plan;
  4. the implementation across plugin and site code;
  5. verification evidence and known gaps;
  6. attribution and license notices for reused code or assets.
提供:
  1. WordPress behavior 和 data 的简明 inventory;
  2. responsibility map 以及 sandboxed/native decision;
  3. data migration 或 seed plan;
  4. plugin code 和 site code 中的 implementation;
  5. verification evidence 和 known gaps;
  6. 对 reused code 或 assets 的 attribution 和 license notices。