Skip to content
wiki.fftac.org

Foundation - Source Excerpt 40

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

$timeline_category   = sanitize_key(wp_unslash((string) ($input['timeline_category'] ?? '')));
    $projection_query    = antichrist_engine_foundation_clean_query_text($input['projection_q'] ?? '', 120);
    $projection_category = sanitize_key(wp_unslash((string) ($input['projection_category'] ?? '')));
    $map_query           = antichrist_engine_foundation_clean_query_text($input['map_q'] ?? '', 120);
    $map_kind            = sanitize_key(wp_unslash((string) ($input['map_kind'] ?? '')));
    $map_category        = sanitize_key(wp_unslash((string) ($input['map_category'] ?? '')));
    $record_query        = antichrist_engine_foundation_clean_record_query($input['record'] ?? '');

    if (!in_array($claim_category, $claim_categories, true)) {
        $claim_category = 'all';
    }

    if (!in_array($claim_verdict, $claim_verdicts, true)) {
        $claim_verdict = 'all';
    }

    if (!in_array($timeline_category, $timeline_categories, true)) {
        $timeline_category = 'all';
    }

    if (!in_array($projection_category, $claim_categories, true)) {
        $projection_category = 'all';
    }

    if (!in_array($map_kind, $map_kinds, true)) {
        $map_kind = 'all';
    }

    if (!in_array($map_category, $claim_categories, true)) {
        $map_category = 'all';
    }

    return array(
        'claim_q'              => $claim_query,
        'claim_q_normalized'   => antichrist_engine_foundation_normalize_search_text($claim_query),
        'claim_category'       => $claim_category ?: 'all',
        'claim_verdict'        => $claim_verdict ?: 'all',
        'timeline_category'    => $timeline_category ?: 'all',
        'projection_q'         => $projection_query,
        'projection_q_normalized' => antichrist_engine_foundation_normalize_search_text($projection_query),
        'projection_category'  => $projection_category ?: 'all',
        'map_q'                => $map_query,
        'map_q_normalized'     => antichrist_engine_foundation_normalize_search_text($map_query),
        'map_kind'             => $map_kind ?: 'all',
        'map_category'         => $map_category ?: 'all',
        'record'               => $record_query,
        'has_record'           => '' !== $record_query,
        'has_claim_filters'    => '' !== $claim_query || 'all' !== $claim_category || 'all' !== $claim_verdict,
        'has_timeline_filters' => 'all' !== $timeline_category,
        'has_projection_filters' => '' !== $projection_query || 'all' !== $projection_category,
        'has_network_filters'  => '' !== $map_query || 'all' !== $map_kind || 'all' !== $map_category,
        'has_filters'          => '' !== $claim_query || 'all' !== $claim_category || 'all' !== $claim_verdict || 'all' !== $timeline_category || '' !== $projection_query || 'all' !== $projection_category || '' !== $map_query || 'all' !== $map_kind || 'all' !== $map_category || '' !== $record_query,
    );
}

/**
 * Validates the public claims endpoint category filter.
 *
 * @param mixed $value Request value.
 * @return bool
 */
function antichrist_engine_foundation_rest_validate_claim_category($value)
{
    if (!is_scalar($value)) {
        return false;
    }

    $category = sanitize_key((string) $value);

    return '' === $category || in_array($category, antichrist_engine_foundation_get_claim_categories(), true);
}

/**
 * Validates the public timeline endpoint category filter.
 *
 * @param mixed $value Request value.
 * @return bool
 */
function antichrist_engine_foundation_rest_validate_timeline_category($value)
{
    if (!is_scalar($value)) {
        return false;
    }

    $category = sanitize_key((string) $value);

    return '' === $category || in_array($category, antichrist_engine_foundation_get_timeline_categories(), true);
}

/**
 * Validates short public REST search filters.
 *
 * @param mixed $value Request value.
 * @return bool
 */
function antichrist_engine_foundation_rest_validate_short_query($value)
{
    return is_scalar($value) && strlen((string) $value) <= 120;
}

/**
 * Builds the response used by the research API overview endpoint.
 *
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_research_api_overview()
{
    $routes  = antichrist_engine_foundation_get_research_api_route_map();
    $payload = antichrist_engine_foundation_get_research_export_payload();
    $map     = $payload['map'] ?? array();

    return array(
        'site'         => array(
            'name'     => antichrist_engine_foundation_identity()['name'],
            'research' => antichrist_engine_foundation_get_page_url('research'),
            'journal'  => antichrist_engine_foundation_get_page_url('journal'),
            'questions'=> antichrist_engine_foundation_get_page_url('questions'),
            'contact'  => antichrist_engine_foundation_get_page_url('contact'),
            'support'  => antichrist_engine_foundation_get_page_url('support'),
            'join'     => antichrist_engine_foundation_get_page_url('join'),
        ),
        'generated_at' => gmdate(DATE_ATOM),
        'counts'       => array(
            'frameworks' => count($payload['frameworks']),
            'timeline'   => count($payload['timeline']),
            'claims'     => count($payload['claims']),
            'projections'=> count($payload['projections']),
            'briefings'  => count($payload['briefings']),
            'signals'    => count($payload['signals']),
            'sources'    => count($payload['sources']),
            'series'     => count($payload['series']),
            'programs'   => count($payload['programs']),
            'map_nodes'  => count($map['nodes'] ?? array()),
            'map_edges'  => count($map['edges'] ?? array()),
            'download_formats' => count(antichrist_engine_foundation_get_research_export_download_route_map()),
        ),
        'routes'       => $routes,
    );
}

/**
 * REST callback for the research overview endpoint.
 *
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_overview($request = null)
{
    return rest_ensure_response(antichrist_engine_foundation_get_research_api_overview());
}

/**
 * REST callback for the research export endpoint.
 *
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_export($request = null)
{
    $payload                 = antichrist_engine_foundation_get_research_export_payload();
    $payload['generated_at'] = gmdate(DATE_ATOM);

    return rest_ensure_response($payload);
}

/**
 * REST callback for claim dossiers.
 *
 * @param WP_REST_Request $request Request object.
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_claims($request)
{
    $items = antichrist_engine_foundation_get_filtered_claim_dossiers($request);

    return rest_ensure_response(array(
        'generated_at' => gmdate(DATE_ATOM),
        'count'        => count($items),
        'items'        => $items,
    ));
}

/**
 * REST callback for timeline entries.
 *
 * @param WP_REST_Request $request Request object.
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_timeline($request)
{
    $items = antichrist_engine_foundation_get_filtered_timeline_entries($request);

    return rest_ensure_response(array(
        'generated_at' => gmdate(DATE_ATOM),
        'count'        => count($items),
        'items'        => $items,
    ));
}

/**
 * REST callback for projection-ledger entries.
 *
 * @param WP_REST_Request $request Request object.
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_projections($request)
{
    $items = antichrist_engine_foundation_get_filtered_projection_ledger_entries($request);

    return rest_ensure_response(array(
        'generated_at' => gmdate(DATE_ATOM),
        'count'        => count($items),
        'items'        => $items,
    ));
}

/**
 * REST callback for framework data.
 *
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_frameworks($request = null)
{
    $items = antichrist_engine_foundation_antichrist_frameworks();

    return rest_ensure_response(array(
        'generated_at' => gmdate(DATE_ATOM),
        'count'        => count($items),
        'items'        => $items,
    ));
}

/**
 * REST callback for briefing data.
 *
 * @return WP_REST_Response
 */
function antichrist_engine_foundation_rest_research_briefings($request = null)
{
    $items = antichrist_engine_foundation_get_enriched_briefings();

    return rest_ensure_response(array(
        'generated_at' => gmdate(DATE_ATOM),
        'count'        => count($items),
        'items'        => $items,
    ));
}

/**
 * REST callback for fact-check summary data.
 *