Files
wp-fedistream/templates/widgets/recent-releases.php
magdev 379fd23be0
All checks were successful
Create Release Package / build-release (push) Successful in 55s
feat: Replace Twig with native PHP templates
- 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>
2026-02-02 22:48:10 +01:00

43 lines
2.1 KiB
PHP

<?php
/**
* Recent Releases Widget Template.
*
* @package WP_FediStream
*
* @var array $posts Array of album data.
*/
// Prevent direct file access.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<?php if ( ! empty( $posts ) && is_array( $posts ) ) : ?>
<ul class="fedistream-widget__list fedistream-widget__list--releases">
<?php foreach ( $posts as $post ) : ?>
<li class="fedistream-widget__item">
<a href="<?php echo esc_url( $post['permalink'] ?? '#' ); ?>" class="fedistream-widget__link">
<?php if ( ! empty( $post['thumbnail'] ) ) : ?>
<img src="<?php echo esc_url( $post['thumbnail'] ); ?>" alt="<?php echo esc_attr( $post['title'] ?? '' ); ?>" class="fedistream-widget__image">
<?php else : ?>
<span class="fedistream-widget__placeholder">
<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>
</span>
<?php endif; ?>
<span class="fedistream-widget__info">
<span class="fedistream-widget__title"><?php echo esc_html( $post['title'] ?? '' ); ?></span>
<?php if ( ! empty( $post['artist_name'] ) ) : ?>
<span class="fedistream-widget__artist"><?php echo esc_html( $post['artist_name'] ); ?></span>
<?php endif; ?>
<?php if ( ! empty( $post['release_date'] ) ) : ?>
<span class="fedistream-widget__date"><?php echo esc_html( $post['release_date'] ); ?></span>
<?php endif; ?>
</span>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<p class="fedistream-widget__empty"><?php esc_html_e( 'No releases yet.', 'wp-fedistream' ); ?></p>
<?php endif; ?>