Skip to content
wiki.fftac.org

Foundation - Source Excerpt 39

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

'evidence_levels'     => array_values($evidence),
    );
}

/**
 * Returns the public research export payload.
 *
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_research_export_payload()
{
    return array(
        'frameworks' => antichrist_engine_foundation_antichrist_frameworks(),
        'timeline'   => antichrist_engine_foundation_get_enriched_timeline_entries(),
        'claims'     => antichrist_engine_foundation_get_enriched_claim_dossiers(),
        'projections'=> antichrist_engine_foundation_get_projection_ledger_entries(),
        'briefings'  => antichrist_engine_foundation_get_enriched_briefings(),
        'fact_check' => antichrist_engine_foundation_get_research_fact_check_summary(),
        'signals'    => antichrist_engine_foundation_contemporary_signals(),
        'sources'    => antichrist_engine_foundation_get_research_api_sources(),
        'series'     => antichrist_engine_foundation_get_research_api_series(),
        'programs'   => antichrist_engine_foundation_get_research_api_programs(),
        'verified_research' => array(
            'protocols' => antichrist_engine_foundation_verified_research_protocols(),
            'lanes'     => antichrist_engine_foundation_verified_research_lanes(),
        ),
        'map'        => antichrist_engine_foundation_get_research_connection_map(),
        'topic_map'  => antichrist_engine_foundation_topic_clusters(),
    );
}

/**
 * Filters claim dossiers using the request query parameters.
 *
 * @param WP_REST_Request $request Request object.
 * @return array<int, array<string, mixed>>
 */
function antichrist_engine_foundation_get_filtered_claim_dossiers($request)
{
    $category = sanitize_key((string) $request->get_param('category'));
    $query    = strtolower(antichrist_engine_security_sanitize_text_field($request->get_param('q'), 120));
    $claims   = antichrist_engine_foundation_get_enriched_claim_dossiers();
    $sources  = antichrist_engine_foundation_research_sources();
    $verdicts = antichrist_engine_foundation_claim_verdicts();
    $levels   = antichrist_engine_foundation_claim_evidence_levels();

    return array_values(array_filter($claims, static function ($claim) use ($category, $query, $sources, $verdicts, $levels) {
        if ($category && $category !== ($claim['category'] ?? '')) {
            return false;
        }

        if (!$query) {
            return true;
        }

        $search_parts = array(
            $claim['title'] ?? '',
            $claim['summary'] ?? '',
            $claim['history'] ?? '',
            $claim['diagnostic'] ?? '',
            $claim['keywords'] ?? '',
            $claim['status'] ?? '',
            $verdicts[$claim['verdict'] ?? '']['label'] ?? '',
            $levels[$claim['evidence'] ?? '']['label'] ?? '',
        );

        foreach (($claim['episodes'] ?? array()) as $episode) {
            if (!is_array($episode)) {
                continue;
            }

            $search_parts[] = implode(' ', array_map('strval', $episode));
        }

        foreach (($claim['source_keys'] ?? array()) as $source_key) {
            if (!isset($sources[$source_key])) {
                continue;
            }

            $search_parts[] = implode(' ', array_map('strval', $sources[$source_key]));
        }

        $haystack = strtolower(wp_strip_all_tags(implode(' ', $search_parts)));

        return false !== strpos($haystack, $query);
    }));
}

/**
 * Filters timeline entries using the request query parameters.
 *
 * @param WP_REST_Request $request Request object.
 * @return array<int, array<string, mixed>>
 */
function antichrist_engine_foundation_get_filtered_timeline_entries($request)
{
    $category = sanitize_key((string) $request->get_param('category'));
    $timeline = antichrist_engine_foundation_get_enriched_timeline_entries();

    if (!$category) {
        return $timeline;
    }

    return array_values(array_filter($timeline, static function ($entry) use ($category) {
        return $category === ($entry['category'] ?? '');
    }));
}

/**
 * Filters projection-ledger entries using the request query parameters.
 *
 * @param WP_REST_Request $request Request object.
 * @return array<int, array<string, mixed>>
 */
function antichrist_engine_foundation_get_filtered_projection_ledger_entries($request)
{
    $category = sanitize_key((string) $request->get_param('category'));
    $query    = antichrist_engine_foundation_normalize_search_text(
        antichrist_engine_security_sanitize_text_field($request->get_param('q'), 120)
    );
    $entries  = antichrist_engine_foundation_get_projection_ledger_entries();

    return array_values(array_filter($entries, static function ($entry) use ($category, $query) {
        if ($category && $category !== ($entry['claim_category'] ?? '')) {
            return false;
        }

        if ('' === $query) {
            return true;
        }

        return false !== strpos((string) ($entry['searchable'] ?? ''), $query);
    }));
}

/**
 * Gets valid claim categories for REST filtering.
 *
 * @return array<int, string>
 */
function antichrist_engine_foundation_get_claim_categories()
{
    return array_values(array_unique(array_filter(array_map(static function ($claim) {
        return sanitize_key((string) ($claim['category'] ?? ''));
    }, antichrist_engine_foundation_claim_dossiers()))));
}

/**
 * Gets valid timeline categories for REST filtering.
 *
 * @return array<int, string>
 */
function antichrist_engine_foundation_get_timeline_categories()
{
    return array_values(array_unique(array_filter(array_map(static function ($entry) {
        return sanitize_key((string) ($entry['category'] ?? ''));
    }, antichrist_engine_foundation_antichrist_timeline()))));
}

/**
 * Gets human-readable claim category labels used across the atlas.
 *
 * @return array<string, string>
 */
function antichrist_engine_foundation_get_claim_category_labels()
{
    return array(
        'texts'        => __('Texts', 'antichrist-engine'),
        'prophecy'     => __('Prophecy', 'antichrist-engine'),
        'technology'   => __('Technology', 'antichrist-engine'),
        'power'        => __('Power', 'antichrist-engine'),
        'church'       => __('Church', 'antichrist-engine'),
        'institutions' => __('Institutions', 'antichrist-engine'),
        'algorithmic'  => __('Algorithmic', 'antichrist-engine'),
    );
}

/**
 * Gets human-readable timeline category labels used across the atlas.
 *
 * @return array<string, string>
 */
function antichrist_engine_foundation_get_timeline_category_labels()
{
    return array(
        'textual'       => __('Texts', 'antichrist-engine'),
        'empire'        => __('Empire', 'antichrist-engine'),
        'church'        => __('Church', 'antichrist-engine'),
        'authoritarian' => __('Authoritarian', 'antichrist-engine'),
        'technology'    => __('Technology', 'antichrist-engine'),
        'algorithmic'   => __('Algorithmic', 'antichrist-engine'),
    );
}

/**
 * Gets valid claim verdict keys for public filtering.
 *
 * @return array<int, string>
 */
function antichrist_engine_foundation_get_claim_verdict_keys()
{
    return array_values(array_keys(antichrist_engine_foundation_claim_verdicts()));
}

/**
 * Sanitizes short user-facing query text while preserving readable casing.
 *
 * @param mixed $value      Raw value.
 * @param int   $max_length Maximum length.
 * @return string
 */
function antichrist_engine_foundation_clean_query_text($value, $max_length = 120)
{
    $cleaned = antichrist_engine_security_sanitize_text_field($value, $max_length);
    $cleaned = preg_replace('/\s+/', ' ', (string) $cleaned);

    return trim((string) $cleaned);
}

/**
 * Gets the sanitized research filter state used by the public atlas UI.
 *
 * @param array<string, mixed>|null $input Optional query source. Defaults to $_GET.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_research_filter_state($input = null)
{
    $input               = is_array($input) ? $input : $_GET;
    $claim_categories    = antichrist_engine_foundation_get_claim_categories();
    $timeline_categories = antichrist_engine_foundation_get_timeline_categories();
    $claim_verdicts      = antichrist_engine_foundation_get_claim_verdict_keys();
    $map_kinds           = array('all', 'source', 'bridge', 'lane');
    $claim_query         = antichrist_engine_foundation_clean_query_text($input['claim_q'] ?? '', 120);
    $claim_category      = sanitize_key(wp_unslash((string) ($input['claim_category'] ?? '')));
    $claim_verdict       = sanitize_key(wp_unslash((string) ($input['claim_verdict'] ?? '')));