Skip to content

Commit c1c83ce

Browse files
Merge pull request #602 from Smartling/WP-982-documentation-update
add namespacer info and update composer, update symfony, add claude docs (WP-982)
2 parents 2bffff7 + d020b73 commit c1c83ce

9 files changed

Lines changed: 2105 additions & 348 deletions

File tree

CLAUDE.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@
77
"repositories": [
88
{
99
"type": "github",
10-
"url": "https://github.com/vsolovei-smartling/retry"
10+
"url": "https://github.com/vsolovei-smartling/namespacer"
1111
}
1212
],
1313
"require": {
1414
"galbar/jsonpath": "^2.0",
15-
"vsolovei-smartling/retry": "^2.0.1",
15+
"jralph/retry": "3.0.0",
1616
"php": ">=8.0",
1717
"monolog/monolog": "~1",
18-
"symfony/dependency-injection": "~2.8",
19-
"symfony/expression-language": "~2.8",
20-
"symfony/config": "~2.8",
21-
"symfony/yaml": "~2.8",
18+
"symfony/dependency-injection": "~5.4",
19+
"symfony/expression-language": "~5.4",
20+
"symfony/config": "~5.4",
21+
"symfony/yaml": "~5.4",
2222
"smartling/api-sdk-php": "3.9.2",
2323
"ext-dom": "*",
2424
"ext-libxml": "*",
2525
"ext-json": "*"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "~9"
28+
"phpunit/phpunit": "~9",
29+
"vsolovei-smartling/namespacer": "dev-master"
2930
},
3031
"config": {
3132
"vendor-dir": "inc/third-party"
@@ -44,6 +45,8 @@
4445
"post-install-cmd": [
4546
],
4647
"post-update-cmd": [
48+
"./inc/third-party/vsolovei-smartling/namespacer/bin/namespacer --composer ./composer.json --package smartling-connector --namespace \"Smartling\\Vendor\" inc",
49+
"php fix-double-namespace.php"
4750
]
4851
}
4952
}

0 commit comments

Comments
 (0)