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

@@ -0,0 +1,50 @@
<?php
/**
* Album card partial template.
*
* @package WP_FediStream
*
* @var array $post Album data array.
*/
// Prevent direct file access.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<article class="fedistream-card fedistream-card--album">
<a href="<?php echo esc_url( $post['permalink'] ?? '' ); ?>" class="fedistream-card__link">
<div class="fedistream-card__image fedistream-card__image--square">
<?php if ( ! empty( $post['thumbnail'] ) ) : ?>
<img src="<?php echo esc_url( $post['thumbnail'] ); ?>" alt="<?php echo esc_attr( $post['title'] ?? '' ); ?>" loading="lazy">
<?php else : ?>
<div class="fedistream-card__placeholder fedistream-card__placeholder--album">
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 14.5c-2.49 0-4.5-2.01-4.5-4.5S9.51 7.5 12 7.5s4.5 2.01 4.5 4.5-2.01 4.5-4.5 4.5zm0-5.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"/></svg>
</div>
<?php endif; ?>
</div>
<div class="fedistream-card__content">
<h3 class="fedistream-card__title"><?php echo esc_html( $post['title'] ?? '' ); ?></h3>
<?php if ( ! empty( $post['artist_name'] ) ) : ?>
<p class="fedistream-card__artist"><?php echo esc_html( $post['artist_name'] ); ?></p>
<?php endif; ?>
<p class="fedistream-card__meta">
<span class="fedistream-card__type"><?php echo esc_html( $post['album_type_label'] ?? '' ); ?></span>
<?php if ( ! empty( $post['release_year'] ) ) : ?>
<span class="fedistream-card__year"><?php echo esc_html( $post['release_year'] ); ?></span>
<?php endif; ?>
</p>
<?php if ( ! empty( $post['total_tracks'] ) && $post['total_tracks'] > 0 ) : ?>
<p class="fedistream-card__stats">
<?php
printf(
/* translators: %d: number of tracks */
esc_html( _n( '%d track', '%d tracks', $post['total_tracks'], 'wp-fedistream' ) ),
(int) $post['total_tracks']
);
?>
</p>
<?php endif; ?>
</div>
</a>
</article>