ralfhortt / wp-cli-theme-sync
WP-CLI commands to detect and sync block theme template and style drift
Package info
github.com/Horttcore/wp-cli-theme-sync
Type:wp-cli-package
pkg:composer/ralfhortt/wp-cli-theme-sync
dev-main
2026-10-27 12:21 UTC
Requires
- php: >=8.2
- ralfhortt/wp-cli-shared: dev-main@dev
- sebastian/diff: ^5.1
- wp-cli/wp-cli: ^2.10
Requires (Dev)
- pestphp/pest: ^2.36
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 07:48:09 UTC
README
WP-CLI commands to detect drift between block theme data stored in WordPress and local theme files.
Installation
Published package:
wp package install ralfhortt/wp-cli-theme-sync
ralfhortt/wp-cli-shared is installed automatically as a Composer dependency.
Local development checkout:
wp package install /absolute/path/to/wp-cli-theme-sync
Commands
| Command | Description |
|---|---|
wp theme-sync status |
Show out-of-sync templates, template parts, and styles |
wp theme-sync diff |
Alias of wp theme-sync status (lists drift, not unified diffs) |
wp theme-sync show <slug> |
Show a unified diff for a single item |
wp theme-sync export |
Export templates, parts, and styles from DB into theme files |
wp theme-sync export-templates |
Export customized templates from DB into templates/*.html |
wp theme-sync export-parts |
Export customized template parts from DB into parts/*.html |
wp theme-sync export-styles |
Export merged styles into theme.json and existing styles/*.json |
Drift states
missing_local- DB item exists but corresponding local file is missingcontent_differs- normalized DB and file content differunmapped_style_change- DB variation change has no corresponding local file (listed by default; only fails exit code with--strict-styles)
Flags
--theme=<slug>target a specific theme--allinclude in-sync rows--type=<type>filter or targettemplate,template_part, orstyles--slug=<slug>filter status output by slug--state=<state>filter status output by drift state--area=<area>disambiguate template parts with the same slug--strict-stylestreat unmapped style variation changes as drift failures (exit code 1 onstatus/diff; errors onexport-styles)--verboseinclude checksum hints in status details--format=table|json|yaml|csvfor status/export output--format=diff|raw-db|raw-fileforshowoutput--context=<lines>context lines for unified diff output (default: 3)--dry-runpreview writes without changing files--forceoverwrite changed existing files during export
Exit codes
0when everything is in sync (or whenshowreports an in-sync item)1when drift exists (or whenshowreports drift). Unmapped style variations alone exit0unless--strict-stylesis set.
Notes
- Comparison is driven by customized templates/parts in the database (Site Editor), not every file on disk.
--themescopes templates, parts, global styles, and export paths to that theme (includingwp_global_stylesfor that stylesheet).export/export-styleswrite merged theme + user global styles intotheme.json(what the site shows), not theme-only defaults.
Examples
wp theme-sync status --path=/path/to/wordpress wp theme-sync status --type=template --state=content_differs --path=/path/to/wordpress wp theme-sync diff --format=json --strict-styles --path=/path/to/wordpress wp theme-sync show single --type=template --path=/path/to/wordpress wp theme-sync show header --type=template_part --area=header --path=/path/to/wordpress wp theme-sync show theme.json --type=styles --path=/path/to/wordpress wp theme-sync show ocean --type=styles --format=raw-db --path=/path/to/wordpress wp theme-sync export --dry-run --path=/path/to/wordpress wp theme-sync export --force --path=/path/to/wordpress wp theme-sync export-styles --force --strict-styles --path=/path/to/wordpress
Development
composer stan
composer lint
composer test