You've already forked wp-fedistream
71 lines
3.4 KiB
PHP
71 lines
3.4 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Featured Artist Widget Template.
|
||
|
|
*
|
||
|
|
* @package WP_FediStream
|
||
|
|
*
|
||
|
|
* @var array $post Artist data array.
|
||
|
|
*/
|
||
|
|
|
||
|
|
// Prevent direct file access.
|
||
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<?php if ( ! empty( $post ) ) : ?>
|
||
|
|
<div class="fedistream-widget__featured">
|
||
|
|
<a href="<?php echo esc_url( $post['permalink'] ?? '#' ); ?>" class="fedistream-widget__featured-link">
|
||
|
|
<?php if ( ! empty( $post['thumbnail'] ) ) : ?>
|
||
|
|
<img src="<?php echo esc_url( $post['thumbnail'] ); ?>" alt="<?php echo esc_attr( $post['title'] ?? '' ); ?>" class="fedistream-widget__featured-image">
|
||
|
|
<?php else : ?>
|
||
|
|
<span class="fedistream-widget__placeholder fedistream-widget__placeholder--large">
|
||
|
|
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
|
||
|
|
</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
</a>
|
||
|
|
<div class="fedistream-widget__featured-info">
|
||
|
|
<h4 class="fedistream-widget__featured-name">
|
||
|
|
<a href="<?php echo esc_url( $post['permalink'] ?? '#' ); ?>"><?php echo esc_html( $post['title'] ?? '' ); ?></a>
|
||
|
|
</h4>
|
||
|
|
<?php if ( ! empty( $post['artist_type_label'] ) ) : ?>
|
||
|
|
<span class="fedistream-widget__featured-type"><?php echo esc_html( $post['artist_type_label'] ); ?></span>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ( ! empty( $post['genres'] ) && is_array( $post['genres'] ) ) : ?>
|
||
|
|
<div class="fedistream-widget__featured-genres">
|
||
|
|
<?php foreach ( array_slice( $post['genres'], 0, 3 ) as $genre ) : ?>
|
||
|
|
<a href="<?php echo esc_url( $genre['url'] ?? '#' ); ?>" class="fedistream-tag fedistream-tag--small"><?php echo esc_html( $genre['name'] ?? '' ); ?></a>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ( ! empty( $post['album_count'] ) || ! empty( $post['track_count'] ) ) : ?>
|
||
|
|
<div class="fedistream-widget__featured-stats">
|
||
|
|
<?php if ( ! empty( $post['album_count'] ) ) : ?>
|
||
|
|
<span>
|
||
|
|
<?php
|
||
|
|
printf(
|
||
|
|
/* translators: %d: number of albums */
|
||
|
|
esc_html( _n( '%d album', '%d albums', $post['album_count'], 'wp-fedistream' ) ),
|
||
|
|
(int) $post['album_count']
|
||
|
|
);
|
||
|
|
?>
|
||
|
|
</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ( ! empty( $post['track_count'] ) ) : ?>
|
||
|
|
<span>
|
||
|
|
<?php
|
||
|
|
printf(
|
||
|
|
/* translators: %d: number of tracks */
|
||
|
|
esc_html( _n( '%d track', '%d tracks', $post['track_count'], 'wp-fedistream' ) ),
|
||
|
|
(int) $post['track_count']
|
||
|
|
);
|
||
|
|
?>
|
||
|
|
</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<?php else : ?>
|
||
|
|
<p class="fedistream-widget__empty"><?php esc_html_e( 'No artist selected.', 'wp-fedistream' ); ?></p>
|
||
|
|
<?php endif; ?>
|