Foundation - Source Excerpt 16
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
'my wordpress site',
);
if (!$site_name || in_array($normalized_site_name, $legacy_site_names, true)) {
$site_name = $identity['name'];
}
return (string) $site_name;
}
/**
* Gets the public site description used in theme-owned metadata.
*
* @return string
*/
function antichrist_engine_foundation_get_site_description()
{
$identity = antichrist_engine_foundation_identity();
$site_description = get_bloginfo('description');
$normalized_site_description = strtolower(trim((string) $site_description));
$placeholder_descriptions = array(
'',
'just another wordpress site',
'just another wordpress blog',
'my wordpress blog',
'my wordpress site',
);
if (in_array($normalized_site_description, $placeholder_descriptions, true)) {
$site_description = $identity['hero_kicker'];
}
return (string) $site_description;
}
/**
* Keeps browser titles aligned with theme-owned institutional branding.
*
* @param array<string, string> $parts WordPress document title parts.
* @return array<string, string>
*/
function antichrist_engine_foundation_filter_document_title_parts($parts)
{
$active_record = antichrist_engine_foundation_get_active_research_record();
if ($active_record && isset($parts['title'])) {
$parts['title'] = sprintf(
/* translators: 1: research record title, 2: research record ID. */
__('%1$s (%2$s)', 'antichrist-engine'),
(string) ($active_record['title'] ?? ''),
(string) ($active_record['record_id'] ?? '')
);
}
if (isset($parts['site'])) {
$parts['site'] = antichrist_engine_foundation_get_site_name();
}
if (isset($parts['tagline'])) {
$parts['tagline'] = antichrist_engine_foundation_get_site_description();
}
return $parts;
}
add_filter('document_title_parts', 'antichrist_engine_foundation_filter_document_title_parts');
/**
* Returns the best available document title for metadata output.
*
* @param string $fallback Default document title.
* @return string
*/
function antichrist_engine_foundation_get_contextual_document_title($fallback = '')
{
$active_record = antichrist_engine_foundation_get_active_research_record();
if (!$active_record) {
return (string) $fallback;
}
return sprintf(
/* translators: 1: research record title, 2: research record ID, 3: site name. */
__('%1$s (%2$s) | %3$s', 'antichrist-engine'),
(string) ($active_record['title'] ?? ''),
(string) ($active_record['record_id'] ?? ''),
antichrist_engine_foundation_get_site_name()
);
}
/**
* Normalizes descriptions for search snippets and social previews.
*
* @param string $description Raw description text.
* @param int $max_length Maximum character length.
* @return string
*/
function antichrist_engine_foundation_normalize_meta_description($description, $max_length = 165)
{
$description = wp_strip_all_tags((string) $description);
$description = preg_replace('/\s+/', ' ', $description);
$description = trim((string) $description);
if (strlen($description) <= $max_length) {
return $description;
}
$description = substr($description, 0, max(1, (int) $max_length - 1));
$description = preg_replace('/\s+\S*$/', '', $description);
return rtrim((string) $description, " \t\n\r\0\x0B.,;:") . '.';
}
/**
* Gets the best available description for the current view.
*
* @return string
*/
function antichrist_engine_foundation_get_meta_description()
{
$identity = antichrist_engine_foundation_identity();
$active_record = antichrist_engine_foundation_get_active_research_record();
if ($active_record) {
return antichrist_engine_foundation_normalize_meta_description(
antichrist_engine_foundation_get_research_record_meta_description($active_record)
);
}
if (is_front_page()) {
return antichrist_engine_foundation_normalize_meta_description($identity['summary']);
}
if (is_singular('post')) {
$description = has_excerpt()
? get_the_excerpt()
: wp_trim_words(wp_strip_all_tags(get_the_content()), 32, '');
return antichrist_engine_foundation_normalize_meta_description($description);
}
if (is_page()) {
$page_key = antichrist_engine_foundation_get_page_key_by_id(get_queried_object_id());
$profile = antichrist_engine_foundation_document_profile($page_key);
if (has_excerpt()) {
return antichrist_engine_foundation_normalize_meta_description(get_the_excerpt());
}
if (!empty($profile['authority'])) {
return antichrist_engine_foundation_normalize_meta_description($profile['authority']);
}
return antichrist_engine_foundation_normalize_meta_description(get_the_content());
}
if (is_search()) {
$query = trim((string) get_search_query());
if ($query) {
return antichrist_engine_foundation_normalize_meta_description(
sprintf(
/* translators: %s is the search query. */
__('Search results for "%s" across Foundation pages, claim dossiers, sources, programs, and journal publications.', 'antichrist-engine'),
$query
)
);
}
return antichrist_engine_foundation_normalize_meta_description(__('Search the Foundation archive, research atlas, source library, programs, and journal publications.', 'antichrist-engine'));
}
if (is_home()) {
$copy = antichrist_engine_foundation_journal_interface_copy();
return antichrist_engine_foundation_normalize_meta_description($copy['hero_lead'] ?? $identity['summary']);
}
if (is_archive()) {
$title = post_type_archive_title('', false) ?: single_cat_title('', false) ?: __('Archive', 'antichrist-engine');
$description = trim(wp_strip_all_tags((string) get_the_archive_description()));
return antichrist_engine_foundation_normalize_meta_description(
$description ?: sprintf(
/* translators: %s is the archive title. */
__('Browse %s entries from the Foundation public record and journal archive.', 'antichrist-engine'),
$title
)
);
}
if (is_404()) {
return antichrist_engine_foundation_normalize_meta_description(__('This page was not found. Use the Research Navigator or search form to find Foundation records, claim dossiers, sources, and publications.', 'antichrist-engine'));
}
return antichrist_engine_foundation_normalize_meta_description($identity['summary']);
}
/**
* Returns the current launch visibility mode.
*
* The site defaults to "public" so production deploys are indexable when
* WordPress Search Engine Visibility allows it. Set the mode to "preview" or
* "private" for review and staging environments that must stay out of search.
*
* @return string
*/
function antichrist_engine_foundation_get_launch_visibility_mode()
{
$mode = '';
if (defined('ANTICHRIST_ENGINE_LAUNCH_VISIBILITY')) {
$mode = (string) ANTICHRIST_ENGINE_LAUNCH_VISIBILITY;
}
if ('' === trim($mode)) {
$environment_mode = getenv('ANTICHRIST_ENGINE_LAUNCH_VISIBILITY');
if (false !== $environment_mode) {
$mode = (string) $environment_mode;
}
}
if ('' === trim($mode)) {
$mode = (string) get_option('antichrist_engine_launch_visibility', 'public');
}
$mode = sanitize_key(trim((string) apply_filters('antichrist_engine_launch_visibility_mode', $mode)));
if (!in_array($mode, array('private', 'preview', 'public'), true)) {
$mode = 'public';
}
return $mode;
}
/**
* Sanitizes the saved launch visibility option.
*
* @param mixed $mode Submitted mode.
* @return string
*/
function antichrist_engine_foundation_sanitize_launch_visibility_option($mode)
{
$mode = sanitize_key(trim((string) $mode));
if (!in_array($mode, array('private', 'preview', 'public'), true)) {
return 'public';
}
return $mode;
}
/**
* Sanitizes the saved public support URL option.
*
* @param mixed $url Submitted URL.
* @return string
*/
function antichrist_engine_foundation_sanitize_support_url_option($url)
{
$url = is_scalar($url) ? trim(wp_unslash((string) $url)) : '';
if ('' === $url) {
return '';
}
$url = filter_var($url, FILTER_SANITIZE_URL);
$is_valid = false !== filter_var($url, FILTER_VALIDATE_URL)