Albums were three hardcoded cards. An album is a chrnx_release term now, with cover, status and listening links; its archive is the album page with an ordered tracklist. A song is a post carrying lyrics and notes, its track number, and the audio. The player is a native audio element, no library and no JavaScript. Platform icons render only when a URL exists, so nothing points at a service the release is not on yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
47 lines
2.0 KiB
PHP
47 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* Track Meta block render.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
$chrnx_post_id = isset( $block->context['postId'] ) ? absint( $block->context['postId'] ) : get_the_ID();
|
|
if ( ! chrnx_is_eligible_editorial_post( $chrnx_post_id ) ) {
|
|
return;
|
|
}
|
|
|
|
$chrnx_release = chrnx_get_track_release( $chrnx_post_id );
|
|
$chrnx_player = chrnx_get_track_player_markup( $chrnx_post_id );
|
|
$chrnx_links = chrnx_get_track_links( $chrnx_post_id );
|
|
$chrnx_number = absint( get_post_meta( $chrnx_post_id, 'chrnx_track_number', true ) );
|
|
|
|
// Nothing invented: without any track data this block stays silent.
|
|
if ( null === $chrnx_release && '' === $chrnx_player && empty( $chrnx_links ) ) {
|
|
return;
|
|
}
|
|
|
|
$chrnx_release_link = null !== $chrnx_release ? get_term_link( $chrnx_release ) : null;
|
|
?>
|
|
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-track-meta' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-label="<?php echo esc_attr__( 'Track details', 'chrnx' ); ?>">
|
|
<?php if ( '' !== $chrnx_player ) : ?>
|
|
<div class="chrnx-track-meta__player"><?php echo $chrnx_player; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
|
<?php endif; ?>
|
|
<div class="chrnx-track-meta__facts">
|
|
<?php if ( null !== $chrnx_release && ! is_wp_error( $chrnx_release_link ) ) : ?>
|
|
<p class="chrnx-track-meta__release">
|
|
<span class="chrnx-track-meta__label"><?php echo esc_html__( 'From', 'chrnx' ); ?></span>
|
|
<a href="<?php echo esc_url( $chrnx_release_link ); ?>"><?php echo esc_html( $chrnx_release->name ); ?></a>
|
|
<?php if ( $chrnx_number > 0 ) : ?>
|
|
<span class="chrnx-track-meta__number">
|
|
<?php
|
|
/* translators: %d: track number within the album. */
|
|
echo esc_html( sprintf( __( 'Track %d', 'chrnx' ), $chrnx_number ) );
|
|
?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php echo chrnx_get_platform_links_markup( $chrnx_links, 'chrnx-platform-links' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
</div>
|
|
</section>
|