You've already forked wp-fedistream
feat: Replace Twig with native PHP templates
All checks were successful
Create Release Package / build-release (push) Successful in 55s
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:
45
templates/widgets/popular-tracks.php
Normal file
45
templates/widgets/popular-tracks.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Popular Tracks Widget Template.
|
||||
*
|
||||
* @package WP_FediStream
|
||||
*
|
||||
* @var array $posts Array of track data.
|
||||
*/
|
||||
|
||||
// Prevent direct file access.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<?php if ( ! empty( $posts ) && is_array( $posts ) ) : ?>
|
||||
<ol class="fedistream-widget__list fedistream-widget__list--tracks">
|
||||
<?php foreach ( $posts as $post ) : ?>
|
||||
<li class="fedistream-widget__item" data-track-id="<?php echo esc_attr( $post['id'] ?? '' ); ?>">
|
||||
<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 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/></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'] ) ) : ?>
|
||||
<span class="fedistream-widget__artist"><?php echo esc_html( $post['artist'] ); ?></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php if ( ! empty( $post['play_count'] ) ) : ?>
|
||||
<span class="fedistream-widget__plays"><?php echo esc_html( number_format( $post['play_count'] ) ); ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<button type="button" class="fedistream-widget__play" data-track-id="<?php echo esc_attr( $post['id'] ?? '' ); ?>" aria-label="<?php esc_attr_e( 'Play', 'wp-fedistream' ); ?>">
|
||||
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php else : ?>
|
||||
<p class="fedistream-widget__empty"><?php esc_html_e( 'No tracks yet.', 'wp-fedistream' ); ?></p>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user