Skip to content
wiki.fftac.org

Foundation - Source Excerpt 03

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

add_action('init', 'antichrist_engine_foundation_sync_site_identity_options', 11);

/**
 * Removes untouched WordPress starter content during prelaunch setup.
 *
 * @return void
 */
function antichrist_engine_foundation_prelaunch_cleanup_default_content()
{
    $version = '1.0.0';

    if (get_option('antichrist_engine_prelaunch_cleanup_version') === $version) {
        return;
    }

    $default_post = get_page_by_path('hello-world', OBJECT, 'post');

    if ($default_post instanceof WP_Post && antichrist_engine_foundation_is_placeholder_publication($default_post)) {
        wp_update_post(array(
            'ID'          => (int) $default_post->ID,
            'post_status' => 'trash',
        ));
    }

    $sample_page = get_page_by_path('sample-page', OBJECT, 'page');

    if ($sample_page instanceof WP_Post && 'sample-page' === sanitize_title((string) ($sample_page->post_name ?: $sample_page->post_title))) {
        wp_update_post(array(
            'ID'          => (int) $sample_page->ID,
            'post_status' => 'trash',
        ));
    }

    update_option('antichrist_engine_prelaunch_cleanup_version', $version);
}
add_action('init', 'antichrist_engine_foundation_prelaunch_cleanup_default_content', 17);

/**
 * Resolves a foundation page key from a page ID.
 *
 * @param int $page_id Page ID.
 * @return string
 */
function antichrist_engine_foundation_get_page_key_by_id($page_id)
{
    $page_id = (int) $page_id;

    foreach (antichrist_engine_foundation_page_definitions() as $key => $definition) {
        if ((int) antichrist_engine_foundation_get_page_id($key) === $page_id) {
            return $key;
        }
    }

    return '';
}

/**
 * Checks whether the given page is part of the foundation structure.
 *
 * @param int $page_id Optional page ID.
 * @return bool
 */
function antichrist_engine_foundation_is_foundation_page($page_id = 0)
{
    $page_id = $page_id ? (int) $page_id : get_queried_object_id();

    return '' !== antichrist_engine_foundation_get_page_key_by_id($page_id);
}

/**
 * Returns the configured navigation items for a menu location.
 *
 * @param string $location Menu location.
 * @return array<int, array<string, string>>
 */
function antichrist_engine_foundation_get_navigation_items($location = 'primary')
{
    $definitions = antichrist_engine_foundation_page_definitions();
    $keys        = array();

    if ('footer' === $location) {
        $keys = array('about', 'questions', 'contact', 'support', 'recovery', 'charter', 'standards', 'texts', 'symbols', 'downloads', 'journal', 'join');
    } else {
        $keys = array('manifesto', 'ai_engine', 'charter', 'philosophy', 'research', 'recovery', 'journal', 'join');
    }

    $items = array();

    foreach ($keys as $key) {
        if (!isset($definitions[$key])) {
            continue;
        }

        $items[] = array(
            'label' => (string) ($definitions[$key]['nav_label'] ?? $definitions[$key]['title']),
            'url'   => antichrist_engine_foundation_get_page_url($key),
        );
    }

    if ('footer' === $location && function_exists('antichrist_engine_membership_get_page_url')) {
        $items[] = array(
            'label' => 'Membership',
            'url'   => antichrist_engine_membership_get_page_url('portal'),
        );
    }

    return $items;
}

/**
 * Renders a curated fallback menu.
 *
 * @param string $location Menu location.
 * @param string $menu_id  HTML menu ID.
 * @return void
 */
function antichrist_engine_foundation_render_fallback_menu($location = 'primary', $menu_id = '')
{
    $items = antichrist_engine_foundation_get_navigation_items($location);
    $path  = isset($GLOBALS['wp']->request) ? trim((string) $GLOBALS['wp']->request, '/') : '';

    if (!$items) {
        return;
    }

    $menu_id_attribute = $menu_id ? ' id="' . esc_attr($menu_id) . '"' : '';

    echo '<ul' . $menu_id_attribute . ' class="menu">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

    foreach ($items as $item) {
        $current_url = $path ? home_url('/' . $path . '/') : home_url('/');
        $is_current  = untrailingslashit($item['url']) === untrailingslashit($current_url);

        echo '<li class="' . esc_attr($is_current ? 'current-menu-item' : '') . '">';
        echo '<a href="' . esc_url($item['url']) . '">' . esc_html($item['label']) . '</a>';
        echo '</li>';
    }

    echo '</ul>';
}

/**
 * Returns footer links for launch-facing governance and discovery pages.
 *
 * @return array<int, array<string, string>>
 */
function antichrist_engine_foundation_get_footer_auxiliary_links()
{
    return array(
        array(
            'label' => __('Review Notices', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('review_notices'),
        ),
        array(
            'label' => __('Privacy Policy', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('privacy'),
        ),
        array(
            'label' => __('Terms of Use', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('terms'),
        ),
        array(
            'label' => __('Community Guidelines', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('community'),
        ),
        array(
            'label' => __('Site Map', 'antichrist-engine'),
            'url'   => antichrist_engine_foundation_get_page_url('sitemap'),
        ),
        array(
            'label' => __('XML Sitemap', 'antichrist-engine'),
            'url'   => home_url('/wp-sitemap.xml'),
        ),
    );
}

/**
 * Returns structured sections for the human-readable HTML sitemap page.
 *
 * @return array<int, array<string, mixed>>
 */
function antichrist_engine_foundation_get_sitemap_sections()
{
    $sections    = array();
    $definitions = antichrist_engine_foundation_page_definitions();

    $record_items = array();
    foreach (array('manifesto', 'charter', 'review_notices', 'philosophy', 'research', 'recovery', 'standards', 'ai_engine', 'texts', 'symbols', 'downloads', 'about', 'questions', 'contact', 'support', 'join', 'journal') as $page_key) {
        if (!isset($definitions[$page_key])) {
            continue;
        }

        $profile = antichrist_engine_foundation_document_profile($page_key);
        $record_items[] = array(
            'title'   => (string) ($definitions[$page_key]['title'] ?? $page_key),
            'summary' => (string) ($profile['authority'] ?? ''),
            'url'     => antichrist_engine_foundation_get_page_url($page_key),
            'meta'    => implode(' / ', array_filter(array(
                $profile['record_id'] ?? '',
                $profile['classification'] ?? '',
            ))),
        );
    }

    if ($record_items) {
        $sections[] = array(
            'id'      => 'foundation-records',
            'eyebrow' => __('Public Files', 'antichrist-engine'),
            'title'   => __('Core public records', 'antichrist-engine'),
            'summary' => __('Canonical pages, research hubs, publication layers, and participation routes that define the public site.', 'antichrist-engine'),
            'items'   => $record_items,
        );
    }

    $reader_items = array();
    foreach (antichrist_engine_foundation_reader_profiles() as $slug => $profile) {
        $reader_items[] = array(
            'title'   => (string) ($profile['title'] ?? $slug),
            'summary' => (string) ($profile['question'] ?? $profile['summary'] ?? ''),
            'url'     => antichrist_engine_foundation_build_target_url('about', array(), 'reader-profile-' . $slug),
            'meta'    => trim(implode(' / ', array_filter(array(
                $profile['eyebrow'] ?? __('Reader route', 'antichrist-engine'),
                $profile['fit'] ?? '',
            )))),
        );
    }

    if ($reader_items) {
        $sections[] = array(
            'id'      => 'reader-routes',
            'eyebrow' => __('Orientation', 'antichrist-engine'),
            'title'   => __('Reader-type entry routes', 'antichrist-engine'),
            'summary' => __('Persona-driven routes for recovering readers, skeptics, media, systems critics, and contributors who need the right first file quickly.', 'antichrist-engine'),
            'items'   => $reader_items,
        );
    }

    $launch_route_items = array();
    foreach (antichrist_engine_foundation_launch_desk_routes() as $route) {
        $launch_route_items[] = array(
            'title'   => (string) ($route['title'] ?? __('Launch route', 'antichrist-engine')),
            'summary' => (string) ($route['summary'] ?? ''),
            'url'     => antichrist_engine_foundation_build_target_url(