52 lines
2.3 KiB
PHP
52 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Project List block render.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 4, 4 );
|
|
$chrnx_terms = get_terms(
|
|
array(
|
|
'taxonomy' => 'chrnx_project',
|
|
'hide_empty' => false,
|
|
)
|
|
);
|
|
if ( is_wp_error( $chrnx_terms ) || empty( $chrnx_terms ) ) {
|
|
return;
|
|
}
|
|
?>
|
|
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-project-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_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 );
|
|
?>
|
|
<article class="chrnx-project-card">
|
|
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
|
|
<a class="chrnx-project-card__link" href="<?php echo esc_url( $chrnx_link ); ?>">
|
|
<?php endif; ?>
|
|
<span class="chrnx-project-card__art">
|
|
<?php
|
|
$chrnx_cover_markup = $chrnx_cover > 0 ? wp_get_attachment_image( $chrnx_cover, 'chrnx-card', false, array( 'class' => 'chrnx-project-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-project', '', 'chrnx-project-card__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
|
|
<?php endif; ?>
|
|
</span>
|
|
<h<?php echo esc_attr( $chrnx_heading ); ?> class="chrnx-project-card__title"><?php echo esc_html( $chrnx_term->name ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
|
|
<?php if ( '' !== $chrnx_status ) : ?>
|
|
<p class="chrnx-project-card__status"><?php echo esc_html( $chrnx_status ); ?></p>
|
|
<?php endif; ?>
|
|
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
|
|
</a>
|
|
<?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 ?>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|