Template Functions - Source Excerpt 02
Summary
This source excerpt preserves a bounded section of 2IA.org/wp-content/themes/twoia-intelligence/inc/template-functions.php so readers can inspect the evidence without opening the full source file.
**Source path:** 2IA.org/wp-content/themes/twoia-intelligence/inc/template-functions.php
$links = array(
array( 'label' => __( 'Start Here', 'two-identities-anonymous' ), 'url' => home_url( '/start-here/' ) ),
array( 'label' => __( 'Issues', 'two-identities-anonymous' ), 'url' => home_url( '/issues/' ) ),
array( 'label' => __( 'Research', 'two-identities-anonymous' ), 'url' => home_url( '/research/' ) ),
array( 'label' => __( 'Resources', 'two-identities-anonymous' ), 'url' => home_url( '/resources/' ) ),
array( 'label' => __( 'Organizations', 'two-identities-anonymous' ), 'url' => home_url( '/organizations/' ) ),
array( 'label' => __( 'Methodology', 'two-identities-anonymous' ), 'url' => home_url( '/methodology/' ) ),
array( 'label' => __( 'About', 'two-identities-anonymous' ), 'url' => home_url( '/about/' ) ),
array( 'label' => __( 'Support', 'two-identities-anonymous' ), 'url' => home_url( '/support/' ), 'class' => 'menu-item--support' ),
);
$output = '';
foreach ( $links as $link ) {
$class = ! empty( $link['class'] ) ? ' class="' . esc_attr( $link['class'] ) . '"' : '';
$output .= sprintf(
'<li%1$s><a href="%2$s">%3$s</a></li>',
$class,
esc_url( $link['url'] ),
esc_html( $link['label'] )
);
}
return $output;
}
add_filter( 'wp_nav_menu_items', 'twoia_primary_menu_items', 10, 2 );
/**
* Footer menu fallback.
*/
function twoia_footer_menu_fallback() {
?>
<ul class="menu footer-menu fallback-menu">
<li><a href="<?php echo esc_url( home_url( '/privacy-policy/' ) ); ?>"><?php esc_html_e( 'Privacy Policy', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/ethics-and-civil-liberties/' ) ); ?>"><?php esc_html_e( 'Ethics', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/public-records-and-foia/' ) ); ?>"><?php esc_html_e( 'Public Records', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/organizations/' ) ); ?>"><?php esc_html_e( 'Organizations', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/corrections-and-right-of-reply/' ) ); ?>"><?php esc_html_e( 'Corrections', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/newsletter/' ) ); ?>"><?php esc_html_e( 'Newsletter', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/lawful-contact/' ) ); ?>"><?php esc_html_e( 'Lawful Contact', 'two-identities-anonymous' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/contact/' ) ); ?>"><?php esc_html_e( 'Contact', 'two-identities-anonymous' ); ?></a></li>
</ul>
<?php
}
/**
* Render related posts by category.
*/
function twoia_related_posts() {
$category_ids = wp_get_post_categories( get_the_ID() );
if ( empty( $category_ids ) ) {
return;
}
$related = new WP_Query(
array(
'category__in' => $category_ids,
'post__not_in' => array( get_the_ID() ),
'posts_per_page' => 3,
'ignore_sticky_posts' => true,
'no_found_rows' => true,
)
);
if ( ! $related->have_posts() ) {
wp_reset_postdata();
return;
}
?>
<section class="section section--compact related-briefings" aria-labelledby="related-briefings-title">
<div class="section-header section-header--row">
<div>
<p class="eyebrow"><?php esc_html_e( 'Adjacent files', 'two-identities-anonymous' ); ?></p>
<h2 id="related-briefings-title"><?php esc_html_e( 'Related briefings', 'two-identities-anonymous' ); ?></h2>
</div>
</div>
<div class="grid grid--cards">
<?php
while ( $related->have_posts() ) {
$related->the_post();
get_template_part( 'template-parts/content', 'card' );
}
wp_reset_postdata();
?>
</div>
</section>
<?php
}
/**
* Render a safe breadcrumb-like context line.
*/
function twoia_context_label() {
if ( is_category() ) {
return single_cat_title( '', false );
}
if ( is_tag() ) {
return single_tag_title( '', false );
}
if ( is_search() ) {
return sprintf(
/* translators: %s: Search query. */
esc_html__( 'Search results for ā%sā', 'two-identities-anonymous' ),
get_search_query()
);
}
if ( is_archive() ) {
return get_the_archive_title();
}
return esc_html__( 'Research', 'two-identities-anonymous' );
}