Foundation - Source Excerpt 30
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
wp_safe_redirect(add_query_arg('contact_status', 'submitted', $redirect_to));
exit;
}
add_action('admin_post_nopriv_antichrist_engine_contact_message', 'antichrist_engine_foundation_handle_contact_message');
add_action('admin_post_antichrist_engine_contact_message', 'antichrist_engine_foundation_handle_contact_message');
/**
* Gets the current contact-desk notice if present.
*
* @return array<string, string>
*/
function antichrist_engine_foundation_contact_get_notice()
{
$status = isset($_GET['contact_status']) ? sanitize_key(wp_unslash($_GET['contact_status'])) : '';
if (!$status) {
return array();
}
$messages = array(
'submitted' => array(
'type' => 'success',
'message' => __('Your message is on file with the contact desk. It can now be routed to the appropriate editorial, research, recovery, or operations lane.', 'antichrist-engine'),
),
'empty_email' => array(
'type' => 'error',
'message' => __('Add an email address so the Foundation can reply to your message.', 'antichrist-engine'),
),
'invalid_email' => array(
'type' => 'error',
'message' => __('That email address is not valid.', 'antichrist-engine'),
),
'invalid_route' => array(
'type' => 'error',
'message' => __('Choose one of the listed contact routes before sending your message.', 'antichrist-engine'),
),
'empty_subject' => array(
'type' => 'error',
'message' => __('Add a subject so the contact desk can route your message correctly.', 'antichrist-engine'),
),
'empty_message' => array(
'type' => 'error',
'message' => __('Write a message before sending the form.', 'antichrist-engine'),
),
'invalid_submission' => array(
'type' => 'error',
'message' => __('The contact message could not be verified. Refresh the page and try again.', 'antichrist-engine'),
),
'rate_limited' => array(
'type' => 'error',
'message' => __('Too many contact attempts were received from this browser or network. Please wait a few minutes and try again.', 'antichrist-engine'),
),
'failed' => array(
'type' => 'error',
'message' => __('The contact message could not be stored just now. Please try again shortly.', 'antichrist-engine'),
),
);
return $messages[$status] ?? array();
}
/**
* Gets the REST namespace used by the public research API.
*
* @return string
*/
function antichrist_engine_foundation_get_research_api_namespace()
{
return 'antichrist-engine/v1';
}
/**
* Returns the public research API route map.
*
* @return array<string, string>
*/
function antichrist_engine_foundation_get_research_api_route_map()
{
$namespace = antichrist_engine_foundation_get_research_api_namespace();
return array(
'overview' => rest_url($namespace . '/research'),
'export' => rest_url($namespace . '/research/export'),
'claims' => rest_url($namespace . '/research/claims'),
'timeline' => rest_url($namespace . '/research/timeline'),
'projections'=> rest_url($namespace . '/research/projections'),
'frameworks' => rest_url($namespace . '/research/frameworks'),
'briefings' => rest_url($namespace . '/research/briefings'),
'fact_check' => rest_url($namespace . '/research/fact-check'),
'map' => rest_url($namespace . '/research/map'),
'sources' => rest_url($namespace . '/research/sources'),
'series' => rest_url($namespace . '/research/series'),
);
}
/**
* Returns direct download URLs for richer research export formats.
*
* @return array<string, string>
*/
function antichrist_engine_foundation_get_research_export_download_route_map()
{
return array(
'claims_csv' => add_query_arg('fftac_download', 'claims_csv', home_url('/')),
'timeline_csv' => add_query_arg('fftac_download', 'timeline_csv', home_url('/')),
'projections_csv' => add_query_arg('fftac_download', 'projections_csv', home_url('/')),
'sources_csv' => add_query_arg('fftac_download', 'sources_csv', home_url('/')),
'records_ndjson'=> add_query_arg('fftac_download', 'records_ndjson', home_url('/')),
'provenance_txt'=> add_query_arg('fftac_download', 'provenance_txt', home_url('/')),
);
}
/**
* Returns public research API endpoint metadata with resolved URLs.
*
* @return array<int, array<string, string>>
*/
function antichrist_engine_foundation_get_research_api_endpoint_items()
{
$route_map = antichrist_engine_foundation_get_research_api_route_map();
$route_keys = array(
'research' => 'overview',
'research/export' => 'export',
'research/claims' => 'claims',
'research/timeline' => 'timeline',
'research/projections'=> 'projections',
'research/frameworks' => 'frameworks',
'research/briefings' => 'briefings',
'research/fact-check' => 'fact_check',
'research/map' => 'map',
'research/sources' => 'sources',
'research/series' => 'series',
);
$items = array();
foreach ((array) (antichrist_engine_foundation_research_api_copy()['endpoints'] ?? array()) as $endpoint) {
$path = (string) ($endpoint['path'] ?? '');
$route_key = $route_keys[$path] ?? '';
if ('' === $path) {
continue;
}
$items[] = array(
'path' => $path,
'label' => (string) ($endpoint['label'] ?? $path),
'description' => (string) ($endpoint['description'] ?? ''),
'route_key' => $route_key,
'url' => (string) ($route_map[$route_key] ?? ''),
);
}
return $items;
}
/**
* Converts a list of export rows into CSV text.
*
* @param array<int, array<string, scalar|null>> $rows Export rows.
* @return string
*/
function antichrist_engine_foundation_convert_rows_to_csv($rows)
{
if (!$rows) {
return '';
}
$headers = array_keys((array) reset($rows));
$lines = array();
$lines[] = implode(',', array_map(static function ($header) {
return '"' . str_replace('"', '""', (string) $header) . '"';
}, $headers));
foreach ($rows as $row) {
$line = array();
foreach ($headers as $header) {
$value = $row[$header] ?? '';
$value = is_scalar($value) || null === $value ? (string) $value : wp_json_encode($value);
$value = str_replace(array("\r\n", "\r"), "\n", $value);
$line[] = '"' . str_replace('"', '""', $value) . '"';
}
$lines[] = implode(',', $line);
}
return implode("\n", $lines) . "\n";
}
/**
* Returns normalized rows for the claims CSV export.
*
* @return array<int, array<string, scalar>>
*/
function antichrist_engine_foundation_get_research_claim_export_rows()
{
$rows = array();
foreach (antichrist_engine_foundation_get_enriched_claim_dossiers() as $claim) {
$rows[] = array(
'record_id' => (string) ($claim['record_id'] ?? ''),
'title' => (string) ($claim['title'] ?? ''),
'category' => (string) ($claim['category'] ?? ''),
'verdict' => (string) ($claim['verdict'] ?? ''),
'evidence' => (string) ($claim['evidence'] ?? ''),
'source_count' => (int) ($claim['source_count'] ?? 0),
'episode_count' => (int) ($claim['episode_count'] ?? 0),
'status' => (string) ($claim['status'] ?? ''),
'keywords' => (string) ($claim['keywords'] ?? ''),
'summary' => (string) ($claim['summary'] ?? ''),
'history' => (string) ($claim['history'] ?? ''),
'diagnostic' => (string) ($claim['diagnostic'] ?? ''),
'source_record_ids' => implode('|', array_map(static function ($source_reference) {
return (string) ($source_reference['record_id'] ?? '');
}, (array) ($claim['source_references'] ?? array()))),
'related_record_ids' => implode('|', array_map(static function ($related_claim) {
return (string) ($related_claim['record_id'] ?? '');
}, (array) ($claim['related_claims'] ?? array()))),
'record_url' => (string) ($claim['record_request_url'] ?? ''),