Foundation - Source Excerpt 28
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
'post_status' => 'private',
'post_title' => $email,
), true);
if (is_wp_error($signup_id)) {
wp_safe_redirect(add_query_arg('signals_status', 'failed', $redirect_to));
exit;
}
update_post_meta($signup_id, '_antichrist_signals_email', $email);
update_post_meta($signup_id, '_antichrist_signals_name', $name);
update_post_meta($signup_id, '_antichrist_signals_interest', $interest);
if (function_exists('antichrist_engine_foundation_participants_database_sync_intake_post')) {
antichrist_engine_foundation_participants_database_sync_intake_post($signup_id, 'signals');
}
wp_safe_redirect(add_query_arg('signals_status', 'subscribed', $redirect_to));
exit;
}
add_action('admin_post_nopriv_antichrist_engine_signals_signup', 'antichrist_engine_foundation_handle_signals_signup');
add_action('admin_post_antichrist_engine_signals_signup', 'antichrist_engine_foundation_handle_signals_signup');
/**
* Gets the current signals-briefing notice if present.
*
* @return array<string, string>
*/
function antichrist_engine_foundation_signals_get_notice()
{
$status = isset($_GET['signals_status']) ? sanitize_key(wp_unslash($_GET['signals_status'])) : '';
if (!$status) {
return array();
}
$messages = array(
'subscribed' => array(
'type' => 'success',
'message' => __('You are on the signals briefing list. Expect short-form releases and archive notices from the editorial desk.', 'antichrist-engine'),
),
'already_subscribed' => array(
'type' => 'success',
'message' => __('That address is already on the briefing list. Your interest notes have been refreshed.', 'antichrist-engine'),
),
'empty_email' => array(
'type' => 'error',
'message' => __('Add an email address to join the briefing list.', 'antichrist-engine'),
),
'invalid_email' => array(
'type' => 'error',
'message' => __('That email address is not valid.', 'antichrist-engine'),
),
'invalid_submission' => array(
'type' => 'error',
'message' => __('The briefing signup could not be verified. Refresh the page and try again.', 'antichrist-engine'),
),
'rate_limited' => array(
'type' => 'error',
'message' => __('Too many briefing signup attempts were received from this browser or network. Please wait a few minutes and try again.', 'antichrist-engine'),
),
'failed' => array(
'type' => 'error',
'message' => __('The briefing signup could not be stored just now. Please try again shortly.', 'antichrist-engine'),
),
);
return $messages[$status] ?? array();
}
/**
* Registers the private post type used for cohort, summit, and affiliate interest intake.
*
* @return void
*/
function antichrist_engine_foundation_register_program_interest_post_type()
{
register_post_type('fftac_program_interest', array(
'labels' => array(
'name' => __('Program Intake', 'antichrist-engine'),
'singular_name' => __('Program Inquiry', 'antichrist-engine'),
),
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'exclude_from_search' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'supports' => array('title'),
'menu_icon' => 'dashicons-groups',
));
}
add_action('init', 'antichrist_engine_foundation_register_program_interest_post_type', 14);
/**
* Builds the storage key used to deduplicate program inquiries.
*
* @param string $email Email address.
* @param string $program Program slug.
* @return string
*/
function antichrist_engine_foundation_program_interest_key($email, $program)
{
return strtolower(trim((string) $email)) . '|' . sanitize_key((string) $program);
}
/**
* Finds an existing program inquiry by email and program slug.
*
* @param string $email Email address.
* @param string $program Program slug.
* @return int
*/
function antichrist_engine_foundation_find_program_interest($email, $program)
{
$key = antichrist_engine_foundation_program_interest_key($email, $program);
$matches = get_posts(array(
'post_type' => 'fftac_program_interest',
'post_status' => 'any',
'posts_per_page' => 1,
'fields' => 'ids',
'meta_key' => '_antichrist_program_interest_key',
'meta_value' => $key,
));
if (!$matches) {
return 0;
}
return (int) $matches[0];
}
/**
* Counts stored public program inquiries.
*
* @return int
*/
function antichrist_engine_foundation_program_interest_count()
{
$counts = wp_count_posts('fftac_program_interest');
return isset($counts->private) ? (int) $counts->private : 0;
}
/**
* Handles public cohort, summit, and affiliate intake submissions.
*
* @return void
*/
function antichrist_engine_foundation_handle_program_interest()
{
check_admin_referer('antichrist_engine_program_interest');
$redirect_to = antichrist_engine_security_get_post_value('redirect_to');
$redirect_to = wp_validate_redirect($redirect_to, home_url('/'));
$submission_error = antichrist_engine_security_validate_form_submission();
if ($submission_error) {
wp_safe_redirect(add_query_arg('program_status', $submission_error, $redirect_to));
exit;
}
if (!antichrist_engine_security_check_rate_limit('program_interest', 6, HOUR_IN_SECONDS)) {
wp_safe_redirect(add_query_arg('program_status', 'rate_limited', $redirect_to));
exit;
}
$name = antichrist_engine_security_sanitize_text_field(antichrist_engine_security_get_post_value('program_name'), 120);
$email = antichrist_engine_security_sanitize_email_field(antichrist_engine_security_get_post_value('program_email'), 190);
$program = sanitize_key(antichrist_engine_security_get_post_value('program_track'));
$role = antichrist_engine_security_sanitize_text_field(antichrist_engine_security_get_post_value('program_role'), 160);
$notes = antichrist_engine_security_sanitize_textarea_field(antichrist_engine_security_get_post_value('program_notes'), 1500);
$options = antichrist_engine_foundation_program_interest_options();
if (!$email) {
wp_safe_redirect(add_query_arg('program_status', 'empty_email', $redirect_to));
exit;
}
if (!is_email($email)) {
wp_safe_redirect(add_query_arg('program_status', 'invalid_email', $redirect_to));
exit;
}
if (!$program || !isset($options[$program])) {
wp_safe_redirect(add_query_arg('program_status', 'invalid_program', $redirect_to));
exit;
}
$existing_id = antichrist_engine_foundation_find_program_interest($email, $program);
$storage_key = antichrist_engine_foundation_program_interest_key($email, $program);
if ($existing_id) {
update_post_meta($existing_id, '_antichrist_program_interest_name', $name);
update_post_meta($existing_id, '_antichrist_program_interest_email', $email);
update_post_meta($existing_id, '_antichrist_program_interest_program', $program);
update_post_meta($existing_id, '_antichrist_program_interest_role', $role);
update_post_meta($existing_id, '_antichrist_program_interest_notes', $notes);
update_post_meta($existing_id, '_antichrist_program_interest_key', $storage_key);
if (function_exists('antichrist_engine_foundation_participants_database_sync_intake_post')) {
antichrist_engine_foundation_participants_database_sync_intake_post($existing_id, 'programs');
}
wp_safe_redirect(add_query_arg('program_status', 'updated', $redirect_to));
exit;
}
$title = sprintf('%s :: %s', $options[$program]['label'], $email);
$inquiry_id = wp_insert_post(array(
'post_type' => 'fftac_program_interest',
'post_status' => 'private',
'post_title' => $title,
), true);
if (is_wp_error($inquiry_id)) {
wp_safe_redirect(add_query_arg('program_status', 'failed', $redirect_to));
exit;
}
update_post_meta($inquiry_id, '_antichrist_program_interest_name', $name);
update_post_meta($inquiry_id, '_antichrist_program_interest_email', $email);
update_post_meta($inquiry_id, '_antichrist_program_interest_program', $program);
update_post_meta($inquiry_id, '_antichrist_program_interest_role', $role);