Skip to content

[CLI] Load WASM-backed WordPress plugins#3624

Draft
adamziel wants to merge 12 commits into
trunkfrom
adamziel/wasm-wordpress-plugin-api
Draft

[CLI] Load WASM-backed WordPress plugins#3624
adamziel wants to merge 12 commits into
trunkfrom
adamziel/wasm-wordpress-plugin-api

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

@adamziel adamziel commented May 13, 2026

What it does

Adds an experimental --wasm-wordpress-plugin=<path> descriptor for loading WordPress plugins backed by PHP.wasm modules.

A descriptor wires together:

{
	"slug": "hello-wasm",
	"extension": {
		"name": "hello_wasm",
		"source": {
			"format": "manifest",
			"manifestUrl": "./dist/hello-wasm/manifest.json"
		}
	},
	"hooks": [
		{
			"type": "filter",
			"hook": "the_content",
			"callback": "hello_wasm_render_content"
		}
	]
}

The CLI loads the PHP.wasm extension before PHP starts, then writes an mu-plugin bootstrap that registers the declared WordPress hooks.

Rationale

The extension loader makes WASM modules available to PHP, but WordPress still needs a conventional PHP entry point for hooks. Installing a generated mu-plugin gives WASM-backed code a WordPress-native loading model: native functions/classes are exposed by the extension, and WordPress integration stays in PHP via add_action() / add_filter().

Implementation

  • Adds readWasmWordPressPluginConfig() and expandWasmWordPressPluginArgs().
  • Resolves local manifestUrl, baseUrl, and bootstrap paths relative to the descriptor file.
  • Adds declarative action / filter hook registration with priority and acceptedArgs.
  • Adds runtimePHPExtensions as the internal bridge from descriptor expansion to existing CLI PHP extension loading.
  • Documents how to create, build, and load a WASM-backed WordPress plugin.
  • Adds packages/php-wasm/compile-extension/examples/hello-dolly-wasm, a complete Hello Dolly-style example with C extension source, PHP bootstrap, descriptor, and run instructions.

Testing instructions

Run:

npx vitest run packages/playground/cli/tests/wasm-wordpress-plugins.spec.ts packages/playground/cli/tests/php-extensions.spec.ts --config packages/playground/cli/vite.config.ts

Also verified:

git diff --check

npx tsc -p packages/playground/cli/tsconfig.lib.json --noEmit --pretty false currently fails in this sparse checkout on missing workspace/build packages such as @php-wasm/node-8-4 and @wp-playground/blueprints.

@adamziel adamziel force-pushed the adamziel/wasm-wordpress-plugin-api branch from 2f8b2e6 to 1482cd4 Compare May 13, 2026 10:09
@adamziel adamziel force-pushed the adamziel/cli-edit-markdown branch from 9dd745c to 316f701 Compare May 13, 2026 10:27
@adamziel adamziel force-pushed the adamziel/cli-edit-markdown branch from 316f701 to 0cc451f Compare May 13, 2026 10:47
@adamziel adamziel force-pushed the adamziel/wasm-wordpress-plugin-api branch from 1482cd4 to 8b888fd Compare May 13, 2026 10:53
@adamziel adamziel force-pushed the adamziel/cli-edit-markdown branch 6 times, most recently from 90ef8b9 to f56274e Compare May 14, 2026 14:58
Base automatically changed from adamziel/cli-edit-markdown to trunk May 14, 2026 15:32
…ess-plugin-api

# Conflicts:
#	packages/php-wasm/universal/public/php-extension-manifest-schema-validator.js
#	packages/php-wasm/universal/public/php-extension-manifest-schema.json
#	packages/php-wasm/universal/src/lib/load-extension.spec.ts
#	packages/php-wasm/universal/src/lib/load-extension.ts
#	packages/playground/cli/README.md
#	packages/playground/cli/src/php-extensions.ts
#	packages/playground/cli/src/run-cli.ts
#	packages/playground/cli/tests/php-extensions.spec.ts
adamziel added 2 commits May 15, 2026 02:06
# Conflicts:
#	CHANGELOG.md
#	packages/docs/site/docs/main/changelog.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant