Virtual Pages - Source Excerpt 49
Summary
This source excerpt preserves a bounded section of 2IA.org/wp-content/themes/twoia-intelligence/inc/virtual-pages.php so readers can inspect the evidence without opening the full source file.
**Source path:** 2IA.org/wp-content/themes/twoia-intelligence/inc/virtual-pages.php
/**
* Render Lexicon.
*/
function twoia_render_lexicon_portal() {
?>
<section class="section section--compact twoia-ia-section" aria-labelledby="twoia-lexicon-title">
<header class="section-header">
<p class="eyebrow"><?php esc_html_e( 'Disambiguation', 'two-identities-anonymous' ); ?></p>
<h2 id="twoia-lexicon-title"><?php esc_html_e( '2IA means this site first, but search intent is messy', 'two-identities-anonymous' ); ?></h2>
<p><?php esc_html_e( 'This lexicon keeps 2IA’s mission clear while capturing confusing search intent and teaching basic domain-authenticity literacy.', 'two-identities-anonymous' ); ?></p>
</header>
<?php
twoia_render_ia_cards(
array(
array( 'title' => __( '2IA.org / Two Identities Of Anonymous', 'two-identities-anonymous' ), 'body' => __( 'The civil-liberties and public-intelligence project focused on surveillance accountability, identity, anonymity, public records, intelligence power, AI governance, and freedom.', 'two-identities-anonymous' ) ),
array( 'title' => __( 'International Intelligence Apparatus', 'two-identities-anonymous' ), 'body' => __( 'A concept for studying intelligence institutions, state continuity, proxy networks, soft power, covert action, SIGINT infrastructure, OSINT pressure, contractors, and oversight gaps.', 'two-identities-anonymous' ) ),
array( 'title' => __( 'Type 2IA wildland fire crews', 'two-identities-anonymous' ), 'body' => __( 'An unrelated wildfire initial-attack crew classification. It is useful to disambiguate, but it is not the mission or directory focus of 2IA.org.', 'two-identities-anonymous' ) ),
array( 'title' => __( 'FANUC M-2iA robots', 'two-identities-anonymous' ), 'body' => __( 'An unrelated industrial robot series. Searchers may land here by acronym; the civil-liberties project is separate.', 'two-identities-anonymous' ) ),
array( 'title' => __( '2IA ligand', 'two-identities-anonymous' ), 'body' => __( 'An unrelated biochemical identifier. It belongs in scientific databases, not in the 2IA public-intelligence mission.', 'two-identities-anonymous' ) ),
array( 'title' => __( 'Homoglyph and punycode risks', 'two-identities-anonymous' ), 'body' => __( 'Lookalike letters, punycode, copied marks, and confusing redirects can spoof domains. Verify the address before trusting contact, donation, or submission routes.', 'two-identities-anonymous' ) ),
)
);
?>
</section>
<section class="section section--compact twoia-page-cta" aria-labelledby="twoia-domain-title">
<h2 id="twoia-domain-title"><?php esc_html_e( 'Domain authenticity check', 'two-identities-anonymous' ); ?></h2>
<p><?php esc_html_e( 'Before trusting a page that claims to be 2IA, check the exact domain, spelling, certificate clues, punycode display, redirect path, email domain, donation provider, and whether the page links back to the same public routes: Start Here, Issues, Research, Resources, Organizations, Methodology, About, and Support.', 'two-identities-anonymous' ); ?></p>
</section>
<section class="section section--compact twoia-page-cta" aria-labelledby="twoia-disambiguation-matters-title">
<h2 id="twoia-disambiguation-matters-title"><?php esc_html_e( 'Why disambiguation matters', 'two-identities-anonymous' ); ?></h2>
<p><?php esc_html_e( 'Search intent, domain trust, identity verification, and public-interest research clarity are not cosmetic. Readers should know whether they are looking at this civil-liberties project, a wildfire crew term, a robotics product, a scientific identifier, or a lookalike domain trying to borrow trust.', 'two-identities-anonymous' ); ?></p>
</section>
<?php
}
/**
* Find a virtual page by slug.
*
* @param string $slug Requested slug.
* @return array|null
*/
function twoia_get_virtual_page( $slug ) {
$pages = twoia_virtual_pages();
$slug = sanitize_title( $slug );
if ( isset( $pages[ $slug ] ) ) {
$page = $pages[ $slug ];
$page['slug'] = $slug;
return $page;
}
return null;
}
/**
* Return a stable URL slug for a virtual page section.
*
* @param array $section Section definition.
* @param int $index Zero-based section index.
* @return string
*/
function twoia_virtual_page_section_slug( $section, $index ) {
$title = isset( $section['title'] ) ? wp_strip_all_tags( $section['title'] ) : '';
$slug = sanitize_title( $title );
if ( '' === $slug ) {
$slug = 'section-' . ( $index + 1 );
}
return $slug;
}
/**
* Find a section-backed child route for a virtual page.
*
* @param string $parent_slug Parent page slug.
* @param string $section_slug Section route slug.
* @return array|null
*/
function twoia_get_virtual_brief_page( $parent_slug, $section_slug ) {
$parent_slug = sanitize_title( $parent_slug );
$section_slug = sanitize_title( $section_slug );
$parent = twoia_get_virtual_page( $parent_slug );
if ( ! $parent ) {
return null;
}
foreach ( $parent['sections'] as $index => $section ) {
if ( twoia_virtual_page_section_slug( $section, $index ) !== $section_slug ) {
continue;
}
$title = isset( $section['title'] ) ? $section['title'] : '';
$body = isset( $section['body'] ) ? $section['body'] : '';
return array(
'title' => $title,
'eyebrow' => sprintf(
/* translators: %s: parent page title. */
__( '%s dossier', 'two-identities-anonymous' ),
$parent['title']
),
'summary' => ! empty( $section['dossier']['summary'] )
? $section['dossier']['summary']
: $body,
'sections' => array(),
'slug' => $parent_slug . '/' . $section_slug,
'route_path' => $parent_slug . '/' . $section_slug,
'route_type' => 'brief',
'parent_slug' => $parent_slug,
'parent_page' => $parent,
'brief_slug' => $section_slug,
'brief_index' => $index,
'brief_section' => $section,
);
}
return null;
}
/**
* Get the current request's virtual page, if any.
*
* @return array|null
*/
function twoia_get_requested_virtual_page() {
if ( is_admin() || wp_doing_ajax() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
return null;
}
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$path = (string) parse_url( $request_uri, PHP_URL_PATH );
$home_path = (string) parse_url( home_url( '/' ), PHP_URL_PATH );
if ( '' !== $home_path && '/' !== $home_path && 0 === strpos( $path, $home_path ) ) {
$path = substr( $path, strlen( $home_path ) );
}
$request_path = trim( $path, '/' );
if ( '' === $request_path ) {
return null;
}
$parts = array_values( array_filter( explode( '/', $request_path ), 'strlen' ) );
if ( 1 === count( $parts ) ) {
$page = twoia_get_virtual_page( $parts[0] );
if ( $page ) {
$page['route_path'] = $page['slug'];
$page['route_type'] = 'page';
}
return $page;
}
if ( 2 === count( $parts ) ) {
return twoia_get_virtual_brief_page( $parts[0], $parts[1] );
}
return null;
}
/**
* Determine whether the virtual fallback should handle this route.
*
* @param string $slug Requested slug.
* @return bool
*/
function twoia_should_render_virtual_page( $slug ) {
$route_path = implode(
'/',
array_filter(
array_map( 'sanitize_title', explode( '/', trim( $slug, '/' ) ) ),
'strlen'
)
);
$page = get_page_by_path( $route_path, OBJECT, 'page' );
if ( $page && 'publish' === get_post_status( $page ) ) {
return false;
}
return true;
}
/**
* Render the requested virtual page before WordPress outputs the 404 template.
*/
function twoia_maybe_render_virtual_page() {
$page = twoia_get_requested_virtual_page();
$route_path = $page && ! empty( $page['route_path'] ) ? $page['route_path'] : ( $page['slug'] ?? '' );
if ( ! $page || ! twoia_should_render_virtual_page( $route_path ) ) {
return;
}
global $wp_query;
status_header( 200 );
if ( $wp_query instanceof WP_Query ) {
$wp_query->is_404 = false;
}
get_header();
if ( ! empty( $page['route_type'] ) && 'brief' === $page['route_type'] ) {
twoia_render_virtual_brief_page_content( $page );
} else {
twoia_render_virtual_page_content( $page );
}
get_footer();
exit;
}
add_action( 'template_redirect', 'twoia_maybe_render_virtual_page', 0 );
/**
* Improve the document title for virtual routes.
*
* @param array $parts Title parts.
* @return array
*/
function twoia_virtual_page_document_title( $parts ) {
$page = twoia_get_requested_virtual_page();
$route_path = $page && ! empty( $page['route_path'] ) ? $page['route_path'] : ( $page['slug'] ?? '' );
if ( $page && twoia_should_render_virtual_page( $route_path ) ) {
$parts['title'] = ! empty( $page['meta_title'] ) ? $page['meta_title'] : $page['title'];
}
return $parts;
}
add_filter( 'document_title_parts', 'twoia_virtual_page_document_title' );