Files
chrnx-dev-wp/blocks/project-detail/render.php
T
2026-08-15 14:19:58 -05:00

40 lines
2.0 KiB
PHP

<?php
/**
* Project Detail block render.
*
* @package CHRNX
*/
$chrnx_term = get_queried_object();
if ( ! $chrnx_term instanceof WP_Term || 'chrnx_project' !== $chrnx_term->taxonomy ) {
return;
}
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_project_status', true );
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_project_cover', true ) );
$chrnx_links = chrnx_get_project_links( $chrnx_term->term_id );
// Without status, description or links there is no second column to fill.
$chrnx_has_intro = '' !== $chrnx_status || '' !== $chrnx_term->description || ! empty( $chrnx_links );
$chrnx_head_class = 'chrnx-project-detail__head' . ( $chrnx_has_intro ? '' : ' is-bare' );
?>
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-project-detail' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<div class="<?php echo esc_attr( $chrnx_head_class ); ?>">
<div class="chrnx-project-detail__art">
<?php if ( $chrnx_cover > 0 ) : ?>
<?php echo wp_get_attachment_image( $chrnx_cover, 'large', false, array( 'class' => 'chrnx-project-detail__cover' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<?php echo chrnx_get_topic_portrait_markup( 'placeholder-project', '', 'chrnx-project-detail__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
<?php endif; ?>
</div>
<div class="chrnx-project-detail__intro">
<?php if ( '' !== $chrnx_status ) : ?>
<p class="chrnx-project-detail__status"><?php echo esc_html( $chrnx_status ); ?></p>
<?php endif; ?>
<?php if ( '' !== $chrnx_term->description ) : ?>
<p class="chrnx-project-detail__description"><?php echo esc_html( $chrnx_term->description ); ?></p>
<?php endif; ?>
<?php echo chrnx_get_platform_links_markup( $chrnx_links, 'chrnx-platform-links', chrnx_get_project_link_slots() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
</section>