Files
chrnx-dev-wp/blocks/footer-content/render.php
T
chrnxandClaude Opus 5 df117e67bb fix: read navigation from WordPress menus
The header and footer had five URLs hardcoded from the local fixtures.
On a site whose pages are named differently, that is five 404s in the
navigation, which is exactly what happened on chrnx.dev.

Both now read an assigned menu and fall back to the built-in pages when
no menu is set or the assigned one is empty.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 19:42:07 -05:00

36 lines
1.5 KiB
PHP

<?php
/**
* Render translated footer navigation and site credit.
*
* @package CHRNX
*/
$chrnx_footer_links = chrnx_get_navigation_links( 'chrnx-footer' );
$chrnx_site_name = get_bloginfo( 'name' );
$chrnx_current_url = chrnx_get_current_navigation_destination();
$chrnx_copyright = sprintf(
/* translators: 1: current year, 2: site name. */
__( '© %1$s %2$s', 'chrnx' ),
wp_date( 'Y' ),
$chrnx_site_name
);
?>
<div
<?php
// WordPress escapes each generated wrapper attribute.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo get_block_wrapper_attributes( array( 'class' => 'chrnx-site-footer__inner' ) );
?>
>
<p class="chrnx-site-footer__site"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $chrnx_site_name ); ?></a></p>
<nav class="chrnx-footer-navigation" aria-label="<?php echo esc_attr__( 'Footer navigation', 'chrnx' ); ?>">
<ul>
<?php foreach ( $chrnx_footer_links as $chrnx_link ) : ?>
<li><a href="<?php echo esc_url( $chrnx_link['url'] ); ?>"<?php echo $chrnx_current_url === $chrnx_link['url'] ? ' aria-current="page"' : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Fixed attribute fragment. ?>><?php echo esc_html( $chrnx_link['label'] ); ?></a></li>
<?php endforeach; ?>
</ul>
</nav>
<p class="chrnx-site-footer__credit"><?php echo esc_html( $chrnx_copyright ); ?></p>
<p class="chrnx-site-footer__line"><?php echo esc_html__( 'Made in Sinaloa, shared from home.', 'chrnx' ); ?></p>
</div>