woocommerce-backend-dev
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWooCommerce Backend Development
WooCommerce后端开发
This skill provides guidance for developing WooCommerce backend PHP code according to project standards and conventions.
本技能提供了根据项目标准和规范开发WooCommerce后端PHP代码的指导。
When to Use This Skill
何时使用此技能
ALWAYS invoke this skill before:
- Writing new PHP unit tests (files)
*Test.php - Creating new PHP classes
- Modifying existing backend PHP code
- Adding hooks or filters
在以下操作前必须调用此技能:
- 编写新的PHP单元测试(文件)
*Test.php - 创建新的PHP类
- 修改现有后端PHP代码
- 添加钩子或过滤器
Instructions
操作指南
Follow WooCommerce project conventions when adding or modifying backend PHP code:
- Creating new code structures: See file-entities.md for conventions on creating classes and organizing files (but for new unit test files see unit-tests.md).
- Naming conventions: See code-entities.md for naming methods, variables, and parameters
- Coding style: See coding-conventions.md for general coding standards and best practices
- Type annotations: See type-annotations.md for PHPStan-aware PHPDoc annotations
- Working with hooks: See hooks.md for hook callback conventions and documentation
- Dependency injection: See dependency-injection.md for DI container usage
- Data integrity: See data-integrity.md for ensuring data integrity when performing CRUD operations
- Writing tests: See unit-tests.md for unit testing conventions
添加或修改后端PHP代码时,请遵循WooCommerce项目规范:
- 创建新代码结构:有关创建类和组织文件的规范,请参阅file-entities.md(但新单元测试文件请参阅unit-tests.md)。
- 命名规范:有关方法、变量和参数的命名规则,请参阅code-entities.md
- 编码风格:有关通用编码标准和最佳实践,请参阅coding-conventions.md
- 类型注解:有关支持PHPStan的PHPDoc注解,请参阅type-annotations.md
- 钩子使用:有关钩子回调规范和文档,请参阅hooks.md
- 依赖注入:有关DI容器的使用,请参阅dependency-injection.md
- 数据完整性:有关执行CRUD操作时确保数据完整性的方法,请参阅data-integrity.md
- 编写测试:有关单元测试规范,请参阅unit-tests.md
Key Principles
核心原则
- Always follow WordPress Coding Standards
- Use class methods instead of standalone functions
- Place new internal classes in by default
src/Internal/ - Use PSR-4 autoloading with namespace
Automattic\WooCommerce - Write comprehensive unit tests for new functionality
- Run linting and tests before committing changes
- 始终遵循WordPress编码标准
- 使用类方法而非独立函数
- 默认将新的内部类放置在目录中
src/Internal/ - 使用带有命名空间的PSR-4自动加载机制
Automattic\WooCommerce - 为新功能编写全面的单元测试
- 提交更改前运行代码检查和测试
Version Information
版本信息
To determine the next WooCommerce version number for annotations:
@since- Read the property in
$versionon the trunk branchincludes/class-woocommerce.php - Remove the suffix if present
-dev - Example: If trunk shows , use
10.4.0-dev@since 10.4.0 - Note: When reviewing PRs against trunk, the version in trunk is correct even if it seems "future" relative to released versions
为注解确定下一个WooCommerce版本号的方法:
@since- 读取主干分支上文件中的
includes/class-woocommerce.php属性$version - 如果存在后缀,请将其移除
-dev - 示例:如果主干分支显示,则使用
10.4.0-dev@since 10.4.0 - 注意:在审核针对主干分支的PR时,即使主干分支的版本相对于已发布版本看起来是“未来版本”,该版本仍然是正确的