feat: Replace Twig with native PHP templates
All checks were successful
Create Release Package / build-release (push) Successful in 55s

- Remove twig/twig dependency from composer.json
- Convert all 25 Twig templates to native PHP templates
- New render() method in Plugin.php using PHP include with output buffering
- New render_partial() helper method for including partials
- Templates support theme overrides via fedistream/ directory
- Reduced plugin size by eliminating Twig and its dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 22:48:10 +01:00
parent 6e45b0b6f1
commit 379fd23be0
57 changed files with 1928 additions and 1559 deletions

View File

@@ -31,7 +31,7 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
- **Language:** PHP 8.3.x
- **Framework:** Latest WordPress Plugin API
- **E-commerce (optional):** WooCommerce 10.0+
- **Template Engine:** Twig 3.0 (via Composer)
- **Template Engine:** Native PHP templates (with theme override support)
- **Communication Protocol:** ActivityPub
- **Wordpress Base Theme** twentytwentyfive
- **Frontend:** Vanilla JavaScript
@@ -658,3 +658,42 @@ if (get_option('wp_fedistream_enable_prometheus', 0) && $this->is_prometheus_act
- Metrics use simple COUNT queries for performance
- ActivityPub followers limited to top 10 to avoid cardinality explosion
- Default disabled (opt-in via Settings > Integrations)
### 2026-02-02 - Native PHP Templates v0.6.0
**Summary:** Removed Twig dependency and converted all templates to native PHP for improved performance and reduced dependencies.
**Changes:**
- Removed `twig/twig` from composer.json dependencies
- Converted all 25 Twig templates to native PHP templates
- Updated `Plugin.php` with new `render()` method using PHP include with output buffering
- Added `render_partial()` helper method for including partials from within templates
- Added `get_template_path()` method supporting theme overrides via `fedistream/` directory
- Reduced plugin package size by removing Twig and its dependencies
**Files Modified:**
- `includes/Plugin.php` - Removed Twig initialization, new native PHP render methods
- `includes/Frontend/template-wrapper.php` - Updated docblock
- `composer.json` - Removed `twig/twig` dependency
**Templates Created (25 PHP files replacing Twig):**
- `templates/partials/` - card-artist.php, card-album.php, card-track.php, card-playlist.php
- `templates/single/` - artist.php, album.php, track.php, playlist.php
- `templates/archive/` - artist.php, album.php, track.php, playlist.php, taxonomy.php
- `templates/shortcodes/` - artist.php, album.php, track.php, playlist.php, player.php, releases-grid.php, tracks-list.php, artists-grid.php
- `templates/widgets/` - recent-releases.php, popular-tracks.php, featured-artist.php, now-playing.php
**Templates Deleted (25 Twig files):**
- All `.twig` files in templates directory
**Benefits:**
- No external template engine dependency
- Improved performance (no Twig compilation)
- Native WordPress template overriding support
- Smaller plugin package size
- Simpler debugging with standard PHP