31 lines
1.9 KiB
PHP
31 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Podcast Metadata block render.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
$chrnx_post_id = isset( $block->context['postId'] ) ? absint( $block->context['postId'] ) : get_the_ID();
|
|
$chrnx_episode = chrnx_sanitize_episode_number( get_post_meta( $chrnx_post_id, 'chrnx_episode_number', true ) );
|
|
$chrnx_duration = chrnx_sanitize_episode_duration( get_post_meta( $chrnx_post_id, 'chrnx_episode_duration', true ) );
|
|
$chrnx_participants = chrnx_sanitize_episode_participants( get_post_meta( $chrnx_post_id, 'chrnx_episode_participants', true ) );
|
|
$chrnx_url = chrnx_sanitize_canonical_episode_url( get_post_meta( $chrnx_post_id, 'canonical_episode_url', true ) );
|
|
if ( 0 === $chrnx_episode && '' === $chrnx_duration && empty( $chrnx_participants ) && '' === $chrnx_url ) {
|
|
return;
|
|
}
|
|
?>
|
|
<dl <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-podcast-meta' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
<?php if ( $chrnx_episode > 0 ) : ?>
|
|
<div class="chrnx-podcast-meta__item"><dt><?php echo esc_html__( 'Episode', 'chrnx' ); ?></dt><dd><?php echo esc_html( number_format_i18n( $chrnx_episode ) ); ?></dd></div>
|
|
<?php endif; ?>
|
|
<?php if ( '' !== $chrnx_duration ) : ?>
|
|
<div class="chrnx-podcast-meta__item"><dt><?php echo esc_html__( 'Duration', 'chrnx' ); ?></dt><dd><?php echo esc_html( $chrnx_duration ); ?></dd></div>
|
|
<?php endif; ?>
|
|
<?php if ( ! empty( $chrnx_participants ) ) : ?>
|
|
<div class="chrnx-podcast-meta__item"><dt><?php echo esc_html__( 'Participants', 'chrnx' ); ?></dt><dd><?php echo esc_html( implode( ', ', $chrnx_participants ) ); ?></dd></div>
|
|
<?php endif; ?>
|
|
<?php if ( '' !== $chrnx_url ) : ?>
|
|
<div class="chrnx-podcast-meta__item"><dt><?php echo esc_html__( 'Episode page', 'chrnx' ); ?></dt><dd><a href="<?php echo esc_url( $chrnx_url ); ?>"><?php echo esc_html__( 'Open canonical episode page', 'chrnx' ); ?></a></dd></div>
|
|
<?php endif; ?>
|
|
</dl>
|