Foundation - Source Excerpt 29
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
update_post_meta($inquiry_id, '_antichrist_program_interest_notes', $notes);
update_post_meta($inquiry_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($inquiry_id, 'programs');
}
wp_safe_redirect(add_query_arg('program_status', 'submitted', $redirect_to));
exit;
}
add_action('admin_post_nopriv_antichrist_engine_program_interest', 'antichrist_engine_foundation_handle_program_interest');
add_action('admin_post_antichrist_engine_program_interest', 'antichrist_engine_foundation_handle_program_interest');
/**
* Gets the current program-intake notice if present.
*
* @return array<string, string>
*/
function antichrist_engine_foundation_program_interest_get_notice()
{
$status = isset($_GET['program_status']) ? sanitize_key(wp_unslash($_GET['program_status'])) : '';
if (!$status) {
return array();
}
$messages = array(
'submitted' => array(
'type' => 'success',
'message' => __('Your program inquiry is on file. Editorial review can now route you toward the right cohort, summit, or contributor lane.', 'antichrist-engine'),
),
'updated' => array(
'type' => 'success',
'message' => __('That program inquiry already existed. Your role and notes have been refreshed.', 'antichrist-engine'),
),
'empty_email' => array(
'type' => 'error',
'message' => __('Add an email address so the editorial team can respond to your program inquiry.', 'antichrist-engine'),
),
'invalid_email' => array(
'type' => 'error',
'message' => __('That email address is not valid.', 'antichrist-engine'),
),
'invalid_program' => array(
'type' => 'error',
'message' => __('Choose one of the listed programs before submitting the intake form.', 'antichrist-engine'),
),
'invalid_submission' => array(
'type' => 'error',
'message' => __('The program inquiry could not be verified. Refresh the page and try again.', 'antichrist-engine'),
),
'rate_limited' => array(
'type' => 'error',
'message' => __('Too many program inquiries were received from this browser or network. Please wait a few minutes and try again.', 'antichrist-engine'),
),
'failed' => array(
'type' => 'error',
'message' => __('The program inquiry could not be stored just now. Please try again shortly.', 'antichrist-engine'),
),
);
return $messages[$status] ?? array();
}
/**
* Registers the private post type used for public contact-desk submissions.
*
* @return void
*/
function antichrist_engine_foundation_register_contact_message_post_type()
{
register_post_type('fftac_contact_message', array(
'labels' => array(
'name' => __('Contact Messages', 'antichrist-engine'),
'singular_name' => __('Contact Message', '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-email-alt2',
));
}
add_action('init', 'antichrist_engine_foundation_register_contact_message_post_type', 14);
/**
* Handles public contact-desk submissions.
*
* @return void
*/
function antichrist_engine_foundation_handle_contact_message()
{
check_admin_referer('antichrist_engine_contact_message');
$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('contact_status', $submission_error, $redirect_to));
exit;
}
if (!antichrist_engine_security_check_rate_limit('contact_message', 4, HOUR_IN_SECONDS)) {
wp_safe_redirect(add_query_arg('contact_status', 'rate_limited', $redirect_to));
exit;
}
$name = antichrist_engine_security_sanitize_text_field(antichrist_engine_security_get_post_value('contact_name'), 120);
$email = antichrist_engine_security_sanitize_email_field(antichrist_engine_security_get_post_value('contact_email'), 190);
$route = sanitize_key(antichrist_engine_security_get_post_value('contact_route'));
$context = antichrist_engine_security_sanitize_text_field(antichrist_engine_security_get_post_value('contact_context'), 160);
$subject = antichrist_engine_security_sanitize_text_field(antichrist_engine_security_get_post_value('contact_subject'), 160);
$message = antichrist_engine_security_sanitize_textarea_field(antichrist_engine_security_get_post_value('contact_message'), 2000);
$routes = antichrist_engine_foundation_contact_channels();
if (!$email) {
wp_safe_redirect(add_query_arg('contact_status', 'empty_email', $redirect_to));
exit;
}
if (!is_email($email)) {
wp_safe_redirect(add_query_arg('contact_status', 'invalid_email', $redirect_to));
exit;
}
if (!$route || !isset($routes[$route])) {
wp_safe_redirect(add_query_arg('contact_status', 'invalid_route', $redirect_to));
exit;
}
if ('' === $subject) {
wp_safe_redirect(add_query_arg('contact_status', 'empty_subject', $redirect_to));
exit;
}
if ('' === $message) {
wp_safe_redirect(add_query_arg('contact_status', 'empty_message', $redirect_to));
exit;
}
$title = antichrist_engine_security_limit_string(sprintf(
'%s :: %s :: %s',
$routes[$route]['label'],
$subject,
$email
), 180);
$message_id = wp_insert_post(array(
'post_type' => 'fftac_contact_message',
'post_status' => 'private',
'post_title' => $title,
), true);
if (is_wp_error($message_id)) {
wp_safe_redirect(add_query_arg('contact_status', 'failed', $redirect_to));
exit;
}
update_post_meta($message_id, '_antichrist_contact_name', $name);
update_post_meta($message_id, '_antichrist_contact_email', $email);
update_post_meta($message_id, '_antichrist_contact_route', $route);
update_post_meta($message_id, '_antichrist_contact_context', $context);
update_post_meta($message_id, '_antichrist_contact_subject', $subject);
update_post_meta($message_id, '_antichrist_contact_message', $message);
if (function_exists('antichrist_engine_foundation_participants_database_sync_intake_post')) {
antichrist_engine_foundation_participants_database_sync_intake_post($message_id, 'contact');
}