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.
78 lines
3.9 KiB
PHP
78 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* Release List block render.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 4, 4 );
|
|
$chrnx_release_order = array( 'el-hermoso-caos', 'ando-bien-arriba', 'aqui-se-rompio-una-jerga', 'side-b' );
|
|
$chrnx_terms = array();
|
|
foreach ( $chrnx_release_order as $chrnx_release_slug ) {
|
|
$chrnx_release_term = get_term_by( 'slug', $chrnx_release_slug, 'chrnx_release' );
|
|
if ( $chrnx_release_term instanceof WP_Term ) {
|
|
$chrnx_terms[] = $chrnx_release_term;
|
|
}
|
|
}
|
|
if ( is_wp_error( $chrnx_terms ) || empty( $chrnx_terms ) ) {
|
|
return;
|
|
}
|
|
?>
|
|
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-release-list' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
<?php
|
|
foreach ( $chrnx_terms as $chrnx_term ) :
|
|
$chrnx_link = get_term_link( $chrnx_term );
|
|
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_release_status', true );
|
|
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_release_cover', true ) );
|
|
$chrnx_links = chrnx_get_release_links( $chrnx_term->term_id );
|
|
?>
|
|
<article class="chrnx-release-card">
|
|
<div class="chrnx-release-card__main">
|
|
<span class="chrnx-release-card__art">
|
|
<?php
|
|
$chrnx_cover_markup = $chrnx_cover > 0 ? wp_get_attachment_image( $chrnx_cover, 'chrnx-card', false, array( 'class' => 'chrnx-release-card__cover' ) ) : '';
|
|
?>
|
|
<?php if ( '' !== $chrnx_cover_markup ) : ?>
|
|
<?php echo $chrnx_cover_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php else : ?>
|
|
<?php echo chrnx_get_topic_portrait_markup( 'placeholder-release', '', 'chrnx-release-card__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
|
|
<?php endif; ?>
|
|
</span>
|
|
<div class="chrnx-release-card__content">
|
|
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
|
|
<a class="chrnx-release-card__title-link" href="<?php echo esc_url( $chrnx_link ); ?>">
|
|
<?php endif; ?>
|
|
<h<?php echo esc_attr( $chrnx_heading ); ?> class="chrnx-release-card__title"><?php echo esc_html( $chrnx_term->name ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
|
|
<?php
|
|
if ( ! is_wp_error( $chrnx_link ) ) :
|
|
?>
|
|
</a><?php endif; ?>
|
|
<?php if ( '' !== $chrnx_status ) : ?>
|
|
<p class="chrnx-release-card__status"><?php echo esc_html( $chrnx_status ); ?></p>
|
|
<?php endif; ?>
|
|
<?php echo chrnx_get_platform_links_markup( $chrnx_links, 'chrnx-platform-links' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<details class="chrnx-release-card__description">
|
|
<summary><?php echo esc_html__( 'Sobre el disco', 'chrnx' ); ?></summary>
|
|
<?php if ( '' !== trim( $chrnx_term->description ) ) : ?>
|
|
<p><?php echo esc_html( $chrnx_term->description ); ?></p>
|
|
<?php else : ?>
|
|
<p><?php echo esc_html__( 'Descripción pendiente.', 'chrnx' ); ?></p>
|
|
<?php endif; ?>
|
|
</details>
|
|
<?php $chrnx_preview_tracks = chrnx_get_release_track_ids( $chrnx_term->slug, 3 ); ?>
|
|
<?php if ( ! empty( $chrnx_preview_tracks ) ) : ?>
|
|
<ol class="chrnx-release-card__tracks">
|
|
<?php foreach ( $chrnx_preview_tracks as $chrnx_track_index => $chrnx_track_id ) : ?>
|
|
<li><span><?php echo esc_html( str_pad( (string) ( $chrnx_track_index + 1 ), 2, '0', STR_PAD_LEFT ) ); ?></span><a href="<?php echo esc_url( get_permalink( $chrnx_track_id ) ); ?>"><?php echo esc_html( get_the_title( $chrnx_track_id ) ); ?></a></li>
|
|
<?php endforeach; ?>
|
|
</ol>
|
|
<?php endif; ?>
|
|
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
|
|
<a class="chrnx-release-card__lyrics" href="<?php echo esc_url( $chrnx_link ); ?>"><?php echo esc_html__( 'Ver letras', 'chrnx' ); ?> <span aria-hidden="true">↗</span></a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|