woocommerce-email-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWooCommerce Email Editor Development
WooCommerce 邮件编辑器开发
This skill provides guidance for developing the WooCommerce block email editor.
本技能为WooCommerce区块邮件编辑器的开发提供指导。
When to Use This Skill
何时使用本技能
Invoke this skill when:
- Setting up local development for the email editor
- Working on email templates or transactional emails
- Modifying the email editor PHP or JS packages
- Testing email sending functionality
在以下场景调用本技能:
- 搭建邮件编辑器的本地开发环境
- 处理邮件模板或事务性邮件
- 修改邮件编辑器的PHP或JS包
- 测试邮件发送功能
Development Environment Setup
开发环境搭建
1. Start WooCommerce wp-env
1. 启动WooCommerce wp-env
sh
pnpm --filter=@woocommerce/plugin-woocommerce -- wp-env startSite runs at by default. If port 8888 is unavailable, wp-env assigns a different port. Check the startup output or run to see your actual URL.
http://localhost:8888wp-env infosh
pnpm --filter=@woocommerce/plugin-woocommerce -- wp-env start站点默认运行在。如果8888端口不可用,wp-env会分配其他端口。请查看启动输出或运行查看实际URL。
http://localhost:8888wp-env info2. Start the watcher
2. 启动监听程序
Watches and builds admin JS files (including the email editor JS package) and syncs Email Editor PHP package changes:
sh
pnpm --filter=@woocommerce/plugin-woocommerce watch:build:admin监听并构建后台JS文件(包括邮件编辑器JS包),并同步邮件编辑器PHP包的变更:
sh
pnpm --filter=@woocommerce/plugin-woocommerce watch:build:admin3. Enable the block email editor feature
3. 启用区块邮件编辑器功能
Visit http://localhost:8888/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=features and enable the block email editor.
4. Edit transactional emails
4. 编辑事务性邮件
Email Testing with Mailpit
使用Mailpit测试邮件
To test email sending locally, use Mailpit as a local SMTP server.
要在本地测试邮件发送功能,可使用Mailpit作为本地SMTP服务器。
Configure SMTP
配置SMTP
Add to :
plugins/woocommerce/.wp-env.override.jsonjson
{
"lifecycleScripts": {
"afterStart": "./tests/e2e-pw/bin/test-env-setup.sh && wp-env run cli wp plugin install wp-mail-smtp --activate"
},
"config": {
"WPMS_ON": true,
"WPMS_MAILER": "smtp",
"WPMS_SMTP_HOST": "host.docker.internal",
"WPMS_SMTP_PORT": "1025",
"WPMS_SMTP_AUTH": false,
"WPMS_SMTP_SECURE": ""
}
}将以下内容添加到:
plugins/woocommerce/.wp-env.override.jsonjson
{
"lifecycleScripts": {
"afterStart": "./tests/e2e-pw/bin/test-env-setup.sh && wp-env run cli wp plugin install wp-mail-smtp --activate"
},
"config": {
"WPMS_ON": true,
"WPMS_MAILER": "smtp",
"WPMS_SMTP_HOST": "host.docker.internal",
"WPMS_SMTP_PORT": "1025",
"WPMS_SMTP_AUTH": false,
"WPMS_SMTP_SECURE": ""
}
}Start Mailpit
启动Mailpit
sh
docker run --rm --name=mailpit -p 1025:1025 -p 8025:8025 -d axllent/mailpitOr if the container already exists:
sh
docker start mailpitsh
docker run --rm --name=mailpit -p 1025:1025 -p 8025:8025 -d axllent/mailpit或者如果容器已存在:
sh
docker start mailpitView emails
查看邮件
Open http://localhost:8025 to see captured emails.
打开http://localhost:8025查看捕获到的邮件。
Restart wp-env
重启wp-env
After creating or modifying , restart the environment:
.wp-env.override.jsonsh
pnpm --filter=@woocommerce/plugin-woocommerce -- wp-env start --update创建或修改后,重启环境:
.wp-env.override.jsonsh
pnpm --filter=@woocommerce/plugin-woocommerce -- wp-env start --updateKey Paths
关键路径
| Path | Description |
|---|---|
| Email Editor PHP package |
| Email Editor JS package |
| Local wp-env config (gitignored) |
| 路径 | 描述 |
|---|---|
| 邮件编辑器PHP包 |
| 邮件编辑器JS包 |
| 本地wp-env配置(已被Git忽略) |
Building the Email Editor Package
构建邮件编辑器包
To rebuild the JS package after changes:
sh
pnpm --filter=@woocommerce/email-editor build修改后重新构建JS包:
sh
pnpm --filter=@woocommerce/email-editor buildTesting the PHP Package
测试PHP包
Run tests from the directory.
packages/php/email-editor/在目录下运行测试。
packages/php/email-editor/Setup
环境搭建
sh
cd packages/php/email-editor
wp-env start
composer dump-autoloadsh
cd packages/php/email-editor
wp-env start
composer dump-autoloadRun integration tests
运行集成测试
sh
wp-env run tests-cli --env-cwd=wp-content/plugins/email-editor ./vendor/bin/phpunit --configuration phpunit-integration.xml.distsh
wp-env run tests-cli --env-cwd=wp-content/plugins/email-editor ./vendor/bin/phpunit --configuration phpunit-integration.xml.distRun a specific test
运行指定测试
sh
wp-env run tests-cli --env-cwd=wp-content/plugins/email-editor ./vendor/bin/phpunit --configuration phpunit-integration.xml.dist --filter Table_Testsh
wp-env run tests-cli --env-cwd=wp-content/plugins/email-editor ./vendor/bin/phpunit --configuration phpunit-integration.xml.dist --filter Table_TestLinting the PHP Package
PHP包代码检查
Run from the directory.
packages/php/email-editor/在目录下运行。
packages/php/email-editor/PHPStan
PHPStan
sh
cd tasks/phpstan && ./run-phpstan.shFor PHP 7 compatibility:
sh
cd tasks/phpstan && ./run-phpstan.sh php7sh
cd tasks/phpstan && ./run-phpstan.sh如需兼容PHP 7:
sh
cd tasks/phpstan && ./run-phpstan.sh php7PHPCS
PHPCS
sh
composer run phpcssh
composer run phpcs