You've already forked wp-fedistream
46 lines
2.3 KiB
PHP
46 lines
2.3 KiB
PHP
|
|
<?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; ?>
|