fix: validate CHRNX editorial fallbacks

This commit is contained in:
chrnx committed 2026-08-11 15:37:25 -05:00
1 parent 89dcc53e02
commit 52f08a1efd
8 files changed
+232 -17

No files matched your search

+22 -10
View File
@@ -14,10 +14,11 @@ $chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 )
$chrnx_topic = chrnx_validate_editorial_term_slug( $chrnx_request['chrnx_topic'] ?? '', 'chrnx_topic' );
$chrnx_language = chrnx_validate_editorial_term_slug( $chrnx_request['chrnx_language'] ?? '', 'chrnx_language' );
$chrnx_search = $chrnx_args['s'] ?? '';
$chrnx_form_url = strtok( get_pagenum_link( 1, false ), '?' );
?>
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-journal-stream' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-labelledby="chrnx-journal-title">
<h<?php echo esc_attr( $chrnx_heading ); ?> id="chrnx-journal-title"><?php echo esc_html__( 'Journal', 'chrnx' ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
<form class="chrnx-journal-stream__filters" method="get" action="<?php echo esc_url( remove_query_arg( array( 'chrnx_topic', 'chrnx_language', 's', 'paged' ) ) ); ?>">
<form class="chrnx-journal-stream__filters" method="get" action="<?php echo esc_url( $chrnx_form_url ); ?>">
<label>
<span><?php echo esc_html__( 'Topic', 'chrnx' ); ?></span>
<select name="chrnx_topic">
@@ -74,18 +75,29 @@ $chrnx_search = $chrnx_args['s'] ?? '';
),
'strlen'
);
$chrnx_links = paginate_links(
array(
'total' => $chrnx_query->max_num_pages,
'current' => $chrnx_args['paged'],
'add_args' => $chrnx_filter_args,
'type' => 'list',
$chrnx_pages = array_unique(
array_filter(
array( 1, $chrnx_args['paged'] - 1, $chrnx_args['paged'], $chrnx_args['paged'] + 1, (int) $chrnx_query->max_num_pages ),
static function ( $chrnx_page ) use ( $chrnx_query ) {
return $chrnx_page >= 1 && $chrnx_page <= $chrnx_query->max_num_pages;
}
)
);
sort( $chrnx_pages, SORT_NUMERIC );
?>
<?php if ( is_string( $chrnx_links ) ) : ?>
<nav class="chrnx-journal-stream__pagination" aria-label="<?php echo esc_attr__( 'Journal pages', 'chrnx' ); ?>"><?php echo wp_kses_post( $chrnx_links ); ?></nav>
<?php endif; ?>
<nav class="chrnx-journal-stream__pagination" aria-label="<?php echo esc_attr__( 'Journal pages', 'chrnx' ); ?>">
<ul class="page-numbers">
<?php foreach ( $chrnx_pages as $chrnx_page ) : ?>
<li>
<?php if ( $chrnx_page === $chrnx_args['paged'] ) : ?>
<span class="page-numbers current" aria-current="page"><?php echo esc_html( number_format_i18n( $chrnx_page ) ); ?></span>
<?php else : ?>
<a class="page-numbers" href="<?php echo esc_url( chrnx_get_journal_page_url( $chrnx_page, $chrnx_filter_args ) ); ?>"><?php echo esc_html( number_format_i18n( $chrnx_page ) ); ?></a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</nav>
<?php endif; ?>
<?php else : ?>
<p class="chrnx-journal-stream__empty"><?php echo esc_html__( 'No journal entries match these filters yet.', 'chrnx' ); ?></p>