feat: add editorial query blocks
This commit is contained in:
24 files changed
+1421
No files matched your search
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/podcast-meta",
|
||||
"version": "0.1.0",
|
||||
"title": "Podcast Metadata",
|
||||
"category": "theme",
|
||||
"description": "Safe episode details for the current post.",
|
||||
"textdomain": "chrnx",
|
||||
"usesContext": ["postId", "postType"],
|
||||
"supports": { "html": false },
|
||||
"render": "file:./render.php"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
Reference in new issue
Block a user