Skip to content
wiki.fftac.org

Foundation - Source Excerpt 15

Back to Foundation

Summary

This source excerpt preserves a bounded section of Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/foundation.php so readers can inspect the evidence without opening the full source file.

**Source path:** Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/foundation.php

'meta'    => (string) ($packet['eyebrow'] ?? __('Publication packet', 'antichrist-engine')),
            );
        }

        $item_list = antichrist_engine_foundation_build_item_list_graph(
            $current_url . '#publication-tracks',
            __('FFTAC publication tracks and routes', 'antichrist-engine'),
            __('Named publication lanes, release-desk roles, and packeted reading paths for verified dossiers, history files, flagship systems essays, and short-form signals briefings.', 'antichrist-engine'),
            $series_items,
            $current_url,
            $website_id,
            $organization_id
        );

        if ($item_list) {
            $graphs[] = $item_list;
        }
    }

    if ('sitemap' === $page_key) {
        $sitemap_items = array();

        foreach (antichrist_engine_foundation_get_sitemap_sections() as $section) {
            $sitemap_items[] = array(
                'title'   => (string) ($section['title'] ?? ''),
                'summary' => (string) ($section['summary'] ?? ''),
                'meta'    => (string) ($section['eyebrow'] ?? ''),
            );
        }

        $item_list = antichrist_engine_foundation_build_item_list_graph(
            $current_url . '#sitemap-sections',
            __('FFTAC site map sections', 'antichrist-engine'),
            __('Human-readable discovery sections covering public files, governance posture, interpretive labs, research records, participation lanes, and machine-readable routes.', 'antichrist-engine'),
            $sitemap_items,
            $current_url,
            $website_id,
            $organization_id
        );

        if ($item_list) {
            $graphs[] = $item_list;
        }
    }

    return $graphs;
}

/**
 * Returns breadcrumb items for the current request.
 *
 * @return array<int, array<string, string>>
 */
function antichrist_engine_foundation_get_breadcrumb_items()
{
    $items = array(
        array(
            'label' => __('Home', 'antichrist-engine'),
            'url'   => home_url('/'),
        ),
    );

    if (is_front_page()) {
        return $items;
    }

    if (is_search()) {
        $items[] = array(
            'label' => __('Search', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_search_url(),
        );

        if (get_search_query()) {
            $items[] = array(
                'label' => sprintf(__('Results for "%s"', 'antichrist-engine'), get_search_query()),
                'url'   => '',
            );
        }

        return $items;
    }

    if (is_singular('post')) {
        $items[] = array(
            'label' => __('Journal', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('journal'),
        );

        $series      = antichrist_engine_post_series();
        $series_slug = antichrist_engine_post_series_slug();

        if ($series && $series_slug) {
            $items[] = array(
                'label' => $series['name'],
                'url'   => add_query_arg('track', $series_slug, antichrist_engine_foundation_get_page_url('journal')),
            );
        }

        $items[] = array(
            'label' => get_the_title(),
            'url'   => '',
        );

        return $items;
    }

    $active_record = antichrist_engine_foundation_get_active_research_record();

    if ($active_record) {
        $page_id    = get_queried_object_id();
        $page_title = get_the_title($page_id);

        $items[] = array(
            'label' => $page_title ?: __('Research Program', 'antichrist-engine'),
            'url'   => $page_id ? get_permalink($page_id) : antichrist_engine_foundation_get_page_url('research'),
        );
        $items[] = array(
            'label' => (string) ($active_record['type_label'] ?? __('Research Record', 'antichrist-engine')),
            'url'   => (string) ($active_record['atlas_url'] ?? antichrist_engine_foundation_get_page_url('research')),
        );
        $items[] = array(
            'label' => (string) ($active_record['title'] ?? $active_record['record_id'] ?? __('Record', 'antichrist-engine')),
            'url'   => '',
        );

        return $items;
    }

    if (is_page()) {
        $page_id   = get_queried_object_id();
        $ancestors = array_reverse(get_post_ancestors($page_id));

        foreach ($ancestors as $ancestor_id) {
            $items[] = array(
                'label' => get_the_title($ancestor_id),
                'url'   => get_permalink($ancestor_id),
            );
        }

        $items[] = array(
            'label' => get_the_title($page_id),
            'url'   => '',
        );

        return $items;
    }

    if (is_home() || is_archive()) {
        $items[] = array(
            'label' => post_type_archive_title('', false) ?: single_cat_title('', false) ?: __('Archive', 'antichrist-engine'),
            'url'   => '',
        );

        return $items;
    }

    if (is_404()) {
        $items[] = array(
            'label' => __('Not Found', 'antichrist-engine'),
            'url'   => '',
        );
    }

    return $items;
}

/**
 * Renders the breadcrumb trail.
 *
 * @param array<int, array<string, string>> $items Breadcrumb items.
 * @return void
 */
function antichrist_engine_foundation_render_breadcrumbs($items = array())
{
    if (count($items) < 2) {
        return;
    }

    echo '<nav class="site-breadcrumbs" aria-label="' . esc_attr__('Breadcrumb', 'antichrist-engine') . '">';
    echo '<ol class="site-breadcrumbs__list">';

    foreach ($items as $index => $item) {
        $is_last = $index === count($items) - 1;
        echo '<li class="site-breadcrumbs__item">';

        if (!$is_last && !empty($item['url'])) {
            echo '<a href="' . esc_url($item['url']) . '">' . esc_html($item['label']) . '</a>';
        } else {
            echo '<span aria-current="' . esc_attr($is_last ? 'page' : 'false') . '">' . esc_html($item['label']) . '</span>';
        }

        echo '</li>';
    }

    echo '</ol>';
    echo '</nav>';
}

/**
 * Gets the canonical URL for the current request.
 *
 * @return string
 */
function antichrist_engine_foundation_get_current_request_url()
{
    if (is_search()) {
        return antichrist_engine_foundation_get_search_url(get_search_query());
    }

    $active_record = antichrist_engine_foundation_get_active_research_record();

    if ($active_record) {
        return (string) ($active_record['record_request_url'] ?? antichrist_engine_foundation_get_page_url('research'));
    }

    if (is_singular()) {
        return (string) get_permalink();
    }

    if (is_home() && !is_front_page()) {
        $posts_page_id = (int) get_option('page_for_posts');

        if ($posts_page_id) {
            return (string) get_permalink($posts_page_id);
        }
    }

    if (is_post_type_archive()) {
        $post_type = get_query_var('post_type');
        $post_type = is_array($post_type) ? reset($post_type) : $post_type;

        if ($post_type) {
            return (string) get_post_type_archive_link((string) $post_type);
        }
    }

    if (is_category() || is_tag() || is_tax()) {
        $term_link = get_term_link(get_queried_object());

        if (!is_wp_error($term_link)) {
            return (string) $term_link;
        }
    }

    if (is_author()) {
        return (string) get_author_posts_url((int) get_queried_object_id());
    }

    if (is_day()) {
        return (string) get_day_link((int) get_query_var('year'), (int) get_query_var('monthnum'), (int) get_query_var('day'));
    }

    if (is_month()) {
        return (string) get_month_link((int) get_query_var('year'), (int) get_query_var('monthnum'));
    }

    if (is_year()) {
        return (string) get_year_link((int) get_query_var('year'));
    }

    global $wp;

    if (isset($wp->request)) {
        $request_path = trim((string) $wp->request, '/');

        return $request_path ? (string) home_url('/' . $request_path . '/') : home_url('/');
    }

    return home_url('/');
}

/**
 * Gets the public site name used in theme-owned metadata.
 *
 * @return string
 */
function antichrist_engine_foundation_get_site_name()
{
    $identity  = antichrist_engine_foundation_identity();
    $site_name = get_bloginfo('name');
    $normalized_site_name = strtolower(trim((string) $site_name));
    $legacy_site_names = array(
        'anti-christ.org',
        'foundation for the anti-christ',
        'foundation for the anti-chirst',
        'foundation for the antichrist',
        'the foundation for the anti-christ',
        'the foundation for the anti-chirst',
        'my wordpress blog',