You've already forked wp-fedistream
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>
90 lines
4.9 KiB
PHP
90 lines
4.9 KiB
PHP
<?php
|
|
/**
|
|
* Album shortcode template.
|
|
*
|
|
* @package WP_FediStream
|
|
*
|
|
* @var array $post Album data array.
|
|
* @var string $layout Layout style (full, card, compact).
|
|
* @var bool $show_tracks Whether to show tracks.
|
|
*/
|
|
|
|
// Prevent direct file access.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
$layout = $layout ?? 'full';
|
|
?>
|
|
<div class="fedistream-shortcode fedistream-shortcode--album fedistream-shortcode--<?php echo esc_attr( $layout ); ?>">
|
|
<div class="fedistream-album">
|
|
<div class="fedistream-album__header">
|
|
<div class="fedistream-album__artwork">
|
|
<?php if ( ! empty( $post['thumbnail'] ) ) : ?>
|
|
<img src="<?php echo esc_url( $post['thumbnail'] ); ?>" alt="<?php echo esc_attr( $post['title'] ?? '' ); ?>" class="fedistream-album__image">
|
|
<?php else : ?>
|
|
<div class="fedistream-album__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>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="fedistream-album__info">
|
|
<?php if ( ! empty( $post['album_type_label'] ) ) : ?>
|
|
<span class="fedistream-album__type-badge"><?php echo esc_html( $post['album_type_label'] ); ?></span>
|
|
<?php endif; ?>
|
|
<h3 class="fedistream-album__title">
|
|
<a href="<?php echo esc_url( $post['permalink'] ?? '#' ); ?>"><?php echo esc_html( $post['title'] ?? '' ); ?></a>
|
|
</h3>
|
|
<?php if ( ! empty( $post['artist_name'] ) ) : ?>
|
|
<p class="fedistream-album__artist">
|
|
<a href="<?php echo esc_url( $post['artist_url'] ?? '#' ); ?>"><?php echo esc_html( $post['artist_name'] ); ?></a>
|
|
</p>
|
|
<?php endif; ?>
|
|
<div class="fedistream-album__meta">
|
|
<?php if ( ! empty( $post['release_date'] ) ) : ?>
|
|
<span class="fedistream-album__date"><?php echo esc_html( $post['release_date'] ); ?></span>
|
|
<?php endif; ?>
|
|
<?php if ( ! empty( $post['total_tracks'] ) ) : ?>
|
|
<span class="fedistream-album__tracks">
|
|
<?php
|
|
printf(
|
|
/* translators: %d: number of tracks */
|
|
esc_html( _n( '%d track', '%d tracks', $post['total_tracks'], 'wp-fedistream' ) ),
|
|
(int) $post['total_tracks']
|
|
);
|
|
?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="fedistream-album__actions">
|
|
<button type="button" class="fedistream-btn fedistream-btn--primary fedistream-btn--play-all" data-album-id="<?php echo esc_attr( $post['id'] ?? '' ); ?>">
|
|
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
|
|
<?php esc_html_e( 'Play', 'wp-fedistream' ); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ( ! empty( $show_tracks ) && ! empty( $post['tracks'] ) && is_array( $post['tracks'] ) ) : ?>
|
|
<div class="fedistream-album__tracklist">
|
|
<div class="fedistream-tracklist">
|
|
<?php foreach ( $post['tracks'] as $index => $track ) : ?>
|
|
<div class="fedistream-tracklist__item" data-track-id="<?php echo esc_attr( $track['id'] ?? '' ); ?>">
|
|
<span class="fedistream-tracklist__number"><?php echo esc_html( $track['track_number'] ?? ( $index + 1 ) ); ?></span>
|
|
<div class="fedistream-tracklist__info">
|
|
<a href="<?php echo esc_url( $track['permalink'] ?? '#' ); ?>" class="fedistream-tracklist__title"><?php echo esc_html( $track['title'] ?? '' ); ?></a>
|
|
</div>
|
|
<?php if ( ! empty( $track['duration_formatted'] ) ) : ?>
|
|
<span class="fedistream-tracklist__duration"><?php echo esc_html( $track['duration_formatted'] ); ?></span>
|
|
<?php endif; ?>
|
|
<button type="button" class="fedistream-tracklist__play" aria-label="<?php esc_attr_e( 'Play', 'wp-fedistream' ); ?>">
|
|
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
|
|
</button>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|