WordPress / WordPress/create-block-theme
Refactor: Extract CBT_Theme_Export service from rest_export_theme
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 417
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Part of #828 (which fulfills #688).
Goal
Same shape as the CBT_Theme_Save extraction, applied to the export flow. Move the orchestration out of rest_export_theme() into a new service class so it can be invoked from REST or CLI without duplication.
Scope
New file: includes/create-theme/theme-export.php
New class: CBT_Theme_Export with one public static method:
public static function to_zip( string $output_path, array $options ): true|WP_Error;
The current REST handler streams the zip back as the HTTP response body. The service writes to a path on disk; the REST wrapper writes to a temp file, streams it, then cleans up. This keeps both REST and CLI consumers symmetric.
REST endpoint update: rest_export_theme() becomes a thin wrapper. URL, permissions, and response semantics do not change.
Tests (PHPUnit, in this PR)
- Each export option (include images, export-ready, translate-ready) produces the expected zip contents
- Output path is honored
- Permission errors / disk failures propagate as
WP_Error - Test fixtures: a small block theme to round-trip
Out of scope
- Any CLI work — separate issue tracked in #828
- Format options other than zip
- Changing the REST endpoint's semantics for existing callers
Acceptance
- Existing REST export behavior is byte-for-byte preserved (compare zip output before/after)
lint:php,test:php,test:unitall green
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rest_export_theme() and the CBT_Theme_Save extraction, then add the service in includes/create-theme/theme-export.php. Use the stated PHPUnit tests and small block-theme fixture to check each export option, output paths, and WP_Error failures. Done means REST output remains byte-for-byte compatible and lint:php, test:php, and test:unit pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100