Unify the editorial canvas across section pages, keep release tracks out of Journal, and give each song a listening surface with audio, metadata, platform links, sharing, and optional featured art. Document and seed the local The No Names fixture without changing production data.
52 lines
2.5 KiB
PHP
52 lines
2.5 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 ) );
|
|
$chrnx_description = (string) get_post_meta( $chrnx_post_id, 'chrnx_track_description', 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 ?>
|
|
<?php if ( '' !== trim( $chrnx_description ) ) : ?>
|
|
<p class="chrnx-track-meta__description"><?php echo esc_html( $chrnx_description ); ?></p>
|
|
<?php endif; ?>
|
|
<button class="chrnx-track-meta__share" type="button" data-chrnx-share data-share-title="<?php echo esc_attr( get_the_title( $chrnx_post_id ) ); ?>" data-share-url="<?php echo esc_url( get_permalink( $chrnx_post_id ) ); ?>"><?php echo esc_html__( 'Compartir', 'chrnx' ); ?></button>
|
|
</div>
|
|
</section>
|