Skip to content
wiki.fftac.org

Foundation - Source Excerpt 12

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

* @param string                          $organization_id  Organization graph ID.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_build_item_list_graph($graph_id, $name, $description, $items, $current_url, $website_id, $organization_id)
{
    $elements = array();

    foreach ((array) $items as $item) {
        $title = trim((string) ($item['title'] ?? $item['label'] ?? $item['name'] ?? ''));

        if ('' === $title) {
            continue;
        }

        $url     = trim((string) ($item['url'] ?? ''));
        $summary = trim((string) ($item['summary'] ?? $item['description'] ?? ''));
        $meta    = trim((string) ($item['meta'] ?? ''));
        $entry   = array(
            '@type'    => 'ListItem',
            'position' => count($elements) + 1,
            'name'     => $title,
        );

        if ('' !== $url || '' !== $summary || '' !== $meta) {
            $entry_item = array(
                '@type' => 'Thing',
                'name'  => $title,
            );

            if ('' !== $url) {
                $entry_item['url'] = $url;
            }

            if ('' !== $summary) {
                $entry_item['description'] = $summary;
            }

            if ('' !== $meta) {
                $entry_item['disambiguatingDescription'] = $meta;
            }

            $entry['item'] = $entry_item;
        }

        $elements[] = $entry;
    }

    if (!$elements) {
        return array();
    }

    return array(
        '@type'           => 'ItemList',
        '@id'             => (string) $graph_id,
        'url'             => (string) $current_url,
        'name'            => (string) $name,
        'description'     => (string) $description,
        'numberOfItems'   => count($elements),
        'itemListOrder'   => 'https://schema.org/ItemListUnordered',
        'itemListElement' => $elements,
        'isPartOf'        => array('@id' => (string) $website_id),
        'publisher'       => array('@id' => (string) $organization_id),
    );
}

/**
 * Normalizes a human-readable format label into an encoding format.
 *
 * @param string $format_label Format label.
 * @return string
 */
function antichrist_engine_foundation_get_encoding_format_for_label($format_label)
{
    $normalized = strtoupper(trim((string) $format_label));
    $formats    = array(
        'CSV'    => 'text/csv',
        'JSON'   => 'application/json',
        'NDJSON' => 'application/x-ndjson',
        'TXT'    => 'text/plain',
    );

    return (string) ($formats[$normalized] ?? 'application/octet-stream');
}

/**
 * Resolves a public theme asset, allowing optional plugins to supply large files.
 *
 * @param string $relative_path Asset path relative to a theme or plugin root.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_resolve_asset($relative_path)
{
    $relative_path = ltrim((string) $relative_path, '/\\');
    $path_segments = preg_split('/[\/\\\\]+/', $relative_path);

    if (in_array('..', (array) $path_segments, true)) {
        $relative_path = '';
    }

    $normalized    = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $relative_path);
    $path          = trailingslashit(get_template_directory()) . $normalized;
    $asset         = array(
        'relative_path' => $relative_path,
        'path'          => $path,
        'url'           => trailingslashit(get_template_directory_uri()) . str_replace('\\', '/', $relative_path),
        'exists'        => file_exists($path),
        'source'        => 'theme',
    );

    $filtered = apply_filters('antichrist_engine_foundation_asset', $asset);

    if (!is_array($filtered)) {
        return $asset;
    }

    return array_merge($asset, array(
        'relative_path' => (string) ($filtered['relative_path'] ?? $asset['relative_path']),
        'path'          => (string) ($filtered['path'] ?? $asset['path']),
        'url'           => (string) ($filtered['url'] ?? $asset['url']),
        'exists'        => !empty($filtered['exists']),
        'source'        => (string) ($filtered['source'] ?? $asset['source']),
    ));
}

/**
 * Describes a public download asset for cards and image viewers.
 *
 * @param string $relative_path Asset path relative to a theme or plugin root.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_describe_download_asset($relative_path)
{
    $asset = antichrist_engine_foundation_resolve_asset($relative_path);

    if (!$asset['exists']) {
        return array_merge($asset, array(
            'type_label'      => strtoupper((string) pathinfo((string) $relative_path, PATHINFO_EXTENSION)),
            'size_label'      => __('Unavailable', 'antichrist-engine'),
            'dimension_label' => '',
            'meta_label'      => __('Unavailable', 'antichrist-engine'),
        ));
    }

    $size_label      = size_format((int) filesize((string) $asset['path']));
    $type_label      = strtoupper((string) pathinfo((string) $asset['path'], PATHINFO_EXTENSION));
    $dimensions      = @getimagesize((string) $asset['path']);
    $dimension_label = is_array($dimensions)
        ? sprintf(
            /* translators: 1: width in pixels, 2: height in pixels */
            __('%1$s x %2$s', 'antichrist-engine'),
            number_format_i18n((int) $dimensions[0]),
            number_format_i18n((int) $dimensions[1])
        )
        : '';
    $parts = array_filter(array($type_label, $dimension_label, $size_label));

    return array_merge($asset, array(
        'type_label'      => $type_label,
        'size_label'      => $size_label,
        'dimension_label' => $dimension_label,
        'meta_label'      => implode(' / ', $parts),
    ));
}

/**
 * Returns the most appropriate social-share image asset for the current view.
 *
 * @param string $page_key Optional foundation page key override.
 * @return array<string, string>
 */
function antichrist_engine_foundation_get_social_share_image_asset($page_key = '')
{
    $default   = array(
        'path' => 'assets/downloads/previews/fftac-foundation-poster-preview.png',
        'alt'  => __('FFTAC public record social preview', 'antichrist-engine'),
    );
    $fallback  = array(
        'path' => 'assets/downloads/seal/fftac-seal-1024.png',
        'alt'  => __('FFTAC public record social preview', 'antichrist-engine'),
    );

    if (is_singular('post')) {
        $featured_image = get_the_post_thumbnail_url(get_the_ID(), 'full');

        if ($featured_image) {
            return array(
                'url' => (string) $featured_image,
                'alt' => sprintf(
                    /* translators: %s is the current post title. */
                    __('Featured image for %s', 'antichrist-engine'),
                    get_the_title()
                ),
            );
        }
    }

    if ('' === $page_key && is_page()) {
        $page_key = antichrist_engine_foundation_get_page_key_by_id(get_queried_object_id());
    }

    $assets = array(
        'contact'        => array(
            'path' => 'assets/downloads/previews/fftac-crest-banner-preview.png',
            'alt'  => __('FFTAC contact desk social preview', 'antichrist-engine'),
        ),
        'downloads'      => array(
            'path' => 'assets/downloads/previews/fftac-foundation-poster-preview.png',
            'alt'  => __('FFTAC downloads library social preview', 'antichrist-engine'),
        ),
        'join'           => array(
            'path' => 'assets/downloads/previews/fftac-foundation-crest-preview.png',
            'alt'  => __('FFTAC participation programs social preview', 'antichrist-engine'),
        ),
        'questions'      => array(
            'path' => 'assets/downloads/previews/fftac-foundation-crest-preview.png',
            'alt'  => __('FFTAC doctrine Q&A social preview', 'antichrist-engine'),
        ),
        'research'       => array(
            'path' => 'assets/downloads/previews/fftac-triune-spiral-poster-preview.png',
            'alt'  => __('FFTAC research atlas social preview', 'antichrist-engine'),
        ),
        'review_notices' => array(
            'path' => 'assets/downloads/seal/fftac-seal-1024.png',
            'alt'  => __('FFTAC review notices social preview', 'antichrist-engine'),
        ),
        'support'        => array(
            'path' => 'assets/downloads/previews/fftac-foundation-crest-preview.png',
            'alt'  => __('FFTAC support brief social preview', 'antichrist-engine'),
        ),
        'symbols'        => array(
            'path' => 'assets/downloads/previews/fftac-symbol-study-parchment-preview.png',
            'alt'  => __('FFTAC symbols lab social preview', 'antichrist-engine'),
        ),
        'texts'          => array(