|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the **Smartling Connector** WordPress plugin - a translation and localization platform integration that seamlessly translates WordPress content through the Smartling API. The plugin handles content upload, translation management, and automatic download of completed translations. |
| 8 | + |
| 9 | +## Key Development Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +- **Unit tests**: `./inc/third-party/phpunit/phpunit/phpunit --configuration ./phpunit.xml.dist` |
| 13 | + |
| 14 | +### Build & Release |
| 15 | +- **Build plugin**: `./build.sh` - Creates production-ready `smartling-connector.zip` |
| 16 | +- **Composer dependencies**: `./composer update` (dev), `./composer update --no-dev` (production) |
| 17 | + |
| 18 | +### Dependency Management |
| 19 | +- Dependencies are installed to `inc/third-party/` (configured in composer.json) |
| 20 | +- Scoped namespacing prevents conflicts with other WordPress plugins, installed to `inc/lib/` (https://github.com/vsolovei-smartling/namespacer) |
| 21 | + |
| 22 | +## Architecture Overview |
| 23 | + |
| 24 | +### Core Components |
| 25 | + |
| 26 | +**Bootstrap Process** (`inc/Smartling/Bootstrap.php`): |
| 27 | +- Main entry point that initializes the plugin |
| 28 | +- Handles dependency injection container setup |
| 29 | +- Registers WordPress hooks and services |
| 30 | +- Manages plugin activation/deactivation |
| 31 | + |
| 32 | +**Content Management**: |
| 33 | +- `ContentTypes/` - Handles different WordPress content types (posts, pages, taxonomies, menus, widgets) |
| 34 | +- `ExternalContent*` - Specialized handlers for third-party plugins (Elementor, Yoast, ACF, Gravity Forms, Beaver Builder) |
| 35 | +- `Submissions/` - Core translation workflow management |
| 36 | + |
| 37 | +**Translation Pipeline**: |
| 38 | +1. **Upload**: Content serialization → Smartling API upload |
| 39 | +2. **Processing**: Translation occurs in Smartling dashboard |
| 40 | +3. **Download**: Completed translations → WordPress content application |
| 41 | + |
| 42 | +**Key Services**: |
| 43 | +- `ApiWrapper` - Smartling API communication layer with retry logic |
| 44 | +- `SubmissionManager` - Translation job lifecycle management |
| 45 | +- `ContentHelper` - WordPress content serialization/deserialization |
| 46 | +- `FieldsFilterHelper` - Field filtering and transformation rules |
| 47 | + |
| 48 | +### Database Layer |
| 49 | +- `DbAl/` - Database abstraction layer |
| 50 | +- `Migrations/` - Schema versioning and updates |
| 51 | +- `WordpressContentEntities/` - WordPress-specific entity handling |
| 52 | + |
| 53 | +### Extensibility |
| 54 | +- `Extensions/` - Plugin extension system for third-party integrations |
| 55 | +- `Tuner/` - Content filtering and rule management |
| 56 | +- `Replacers/` - Content transformation during translation |
| 57 | + |
| 58 | +## Testing Structure |
| 59 | + |
| 60 | +**Unit Tests** (`tests/`): |
| 61 | +- Test individual components in isolation |
| 62 | +- Mock dependencies for fast execution |
| 63 | +- Run with: `./inc/third-party/phpunit/phpunit/phpunit --configuration ./phpunit.xml.dist` |
| 64 | + |
| 65 | +**Integration Tests** (`tests/IntegrationTests/`): |
| 66 | +- Full WordPress environment testing |
| 67 | +- Real database operations |
| 68 | +- Third-party plugin compatibility testing |
| 69 | +- Run with: `phpunit -c tests/phpunit.xml` |
| 70 | + |
| 71 | +**Docker Testing**: |
| 72 | +- Complete isolated environment with MySQL |
| 73 | +- Automated via `Buildplan/test.sh` |
| 74 | +- Includes WordPress multisite configuration |
| 75 | + |
| 76 | +## Configuration |
| 77 | + |
| 78 | +**Service Configuration** (`inc/config/`): |
| 79 | +- `services.yml` - Dependency injection container setup |
| 80 | +- `boot.yml` - Bootstrap configuration |
| 81 | +- `field-processor.yml` - Content processing rules |
| 82 | +- `media-attachment-rules.yml` - Media handling rules |
| 83 | + |
| 84 | +**Key Settings**: |
| 85 | +- Content type auto-discovery |
| 86 | +- Field filtering rules |
| 87 | +- Translation workflow configuration |
| 88 | +- Third-party plugin integration settings |
| 89 | + |
| 90 | +## Development Guidelines |
| 91 | + |
| 92 | +### Code Structure |
| 93 | +- PSR-0 autoloading with `Smartling\` namespace |
| 94 | +- Dependency injection throughout the codebase |
| 95 | +- Extensive use of interfaces for testability |
| 96 | +- WordPress hooks for extensibility |
| 97 | + |
| 98 | +### Content Processing |
| 99 | +- All content goes through serialization/deserialization pipeline |
| 100 | +- Field-level filtering for translation control |
| 101 | +- Relationship tracking between original and translated content |
| 102 | +- Gutenberg block-level translation support |
| 103 | + |
| 104 | +### API Integration |
| 105 | +- Robust error handling and retry mechanisms |
| 106 | +- Job-based translation workflow |
| 107 | +- Progress tracking and status reporting |
| 108 | +- Webhook support for real-time updates |
| 109 | + |
| 110 | +### Third-party Compatibility |
| 111 | +- Modular extension system for popular WordPress plugins |
| 112 | +- Page builder support (Elementor, Beaver Builder) |
| 113 | +- SEO plugin integration (Yoast, All in One SEO) |
| 114 | +- Form plugin support (Gravity Forms) |
| 115 | +- Advanced Custom Fields (ACF) support |
| 116 | + |
| 117 | +## Common Workflows |
| 118 | + |
| 119 | +When working on content type support, examine existing `ContentTypes/` implementations. For API changes, check both `ApiWrapper` and related tests. For field processing modifications, review `FieldsFilterHelper` and corresponding configuration files. |
| 120 | + |
| 121 | +### Elementor Widget Development |
| 122 | + |
| 123 | +When adding or modifying Elementor widget support, refer to the comprehensive guide: |
| 124 | +- **Elementor Development Guide**: `docs/ELEMENTOR_DEVELOPMENT.md` |
| 125 | +- Contains patterns for processing related content, testing strategies, and real-world examples |
| 126 | +- Essential reading for WP-* tickets involving Elementor widgets |
0 commit comments