Skip to content
wiki.fftac.org

wiki.fftac.org Core - Source Excerpt 07

Back to wiki.fftac.org Core

Summary

This source excerpt preserves a bounded section of Wiki.FFTAC.org/wp-content/plugins/wiki-fftac-core/wiki-fftac-core.php so readers can inspect the evidence without opening the full source file.

**Source path:** Wiki.FFTAC.org/wp-content/plugins/wiki-fftac-core/wiki-fftac-core.php

get_header();
	?>
	<main id="main" class="aiwikis-main">
		<article class="aiwikis-article aiwikis-file-page">
			<?php aiwikis_core_render_memory_navigation(); ?>
			<h1><?php echo esc_html__( 'Page Not Found', 'aiwikis-core' ); ?></h1>
			<div class="aiwikis-content">
				<p><?php echo esc_html__( 'wiki.fftac.org could not find a reviewed Markdown page for this route.', 'aiwikis-core' ); ?></p>
				<ul>
					<li><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html__( 'wiki.fftac.org', 'aiwikis-core' ); ?></a></li>
					<li><a href="<?php echo esc_url( home_url( '/search/' ) ); ?>"><?php echo esc_html__( 'Search Reviewed Memory', 'aiwikis-core' ); ?></a></li>
					<li><a href="<?php echo esc_url( home_url( '/workspace-current-state/' ) ); ?>"><?php echo esc_html__( 'Workspace Current State', 'aiwikis-core' ); ?></a></li>
					<li><a href="<?php echo esc_url( home_url( '/transfer-log/' ) ); ?>"><?php echo esc_html__( 'Transfer Log', 'aiwikis-core' ); ?></a></li>
					<li><a href="<?php echo esc_url( home_url( '/memory/sources/' ) ); ?>"><?php echo esc_html__( 'All Memory Sources', 'aiwikis-core' ); ?></a></li>
				</ul>
			</div>
		</article>
	</main>
	<?php
	get_footer();
	exit;
}

/**
 * Render a file-backed public content page and stop WordPress fallback routing.
 *
 * @param array<string,mixed> $page Content page record.
 */
function aiwikis_core_render_content_page_response( array $page ): void {
	$title = isset( $page['title'] ) ? (string) $page['title'] : 'wiki.fftac.org';
	$body  = isset( $page['body'] ) ? (string) $page['body'] : '';
	$html  = do_shortcode( aiwikis_core_render_content_markdown( $body, $title ) );

	$GLOBALS['aiwikis_core_current_content_page'] = $page;

	status_header( 200 );
	get_header();
	?>
	<main id="main" class="aiwikis-main">
		<article class="aiwikis-article aiwikis-file-page">
			<?php aiwikis_core_render_memory_navigation(); ?>
			<?php aiwikis_core_render_breadcrumbs( $page ); ?>
			<h1><?php echo esc_html( $title ); ?></h1>
			<?php aiwikis_core_render_page_context( $page ); ?>
			<div class="aiwikis-content">
				<?php echo wp_kses_post( $html ); ?>
			</div>
		</article>
	</main>
	<?php
	get_footer();
	exit;
}

/**
 * Use the file-backed page title for Markdown-routed public pages.
 */
function aiwikis_core_filter_content_page_title( string $title ): string {
	if ( isset( $GLOBALS['aiwikis_core_current_content_page']['title'] ) ) {
		return wp_strip_all_tags( (string) $GLOBALS['aiwikis_core_current_content_page']['title'] ) . ' | wiki.fftac.org';
	}

	return $title;
}
add_filter( 'pre_get_document_title', 'aiwikis_core_filter_content_page_title', 30 );

/**
 * Return public-safe source records.
 *
 * @return array<int,array<string,mixed>>
 */
function aiwikis_core_get_public_source_records(): array {
	$manifest = aiwikis_core_get_source_manifest();
	$records  = isset( $manifest['records'] ) && is_array( $manifest['records'] ) ? $manifest['records'] : array();
	$public   = array();

	foreach ( $records as $record ) {
		if ( ! is_array( $record ) ) {
			continue;
		}

		$public[] = array(
			'source_name'  => sanitize_text_field( (string) ( $record['source_name'] ?? '' ) ),
			'url'          => esc_url_raw( (string) ( $record['url'] ?? '' ) ),
			'fetched_at'   => sanitize_text_field( (string) ( $record['fetched_at'] ?? '' ) ),
			'content_type' => sanitize_text_field( (string) ( $record['content_type'] ?? '' ) ),
			'sha256'       => sanitize_text_field( (string) ( $record['sha256'] ?? '' ) ),
			'source_role'  => sanitize_text_field( (string) ( $record['source_role'] ?? '' ) ),
			'allowed_use'  => sanitize_text_field( (string) ( $record['allowed_use'] ?? '' ) ),
			'status'       => sanitize_text_field( (string) ( $record['status'] ?? 'ok' ) ),
		);
	}

	return $public;
}

/**
 * Return source package metadata safe for public output.
 *
 * @return array<string,mixed>
 */
function aiwikis_core_get_source_package_metadata(): array {
	$manifest = aiwikis_core_read_json_file( aiwikis_core_get_source_package_manifest_path() );

	if ( ! empty( $manifest ) ) {
		return $manifest;
	}

	return array(
		'name'               => 'WP-FFTAC source packages and archive references',
		'version'            => AIWIKIS_CORE_VERSION,
		'package_url'        => home_url( '/transfer-log/' ),
		'source_attribution' => array(
			array(
				'name' => '2IA.org',
				'url'  => 'https://2ia.org/',
				'role' => 'source site',
			),
			array(
				'name' => 'FFTAC.org',
				'url'  => 'https://fftac.org/',
				'role' => 'primary source site',
			),
			array(
				'name' => 'Anti-Christ.net',
				'url'  => 'https://anti-christ.net/',
				'role' => 'source site',
			),
			array(
				'name' => 'Antichrist.net',
				'url'  => 'https://antichrist.net/',
				'role' => 'source site',
			),
			array(
				'name' => 'Anti-Christ.org',
				'url'  => 'https://anti-christ.org/',
				'role' => 'source site',
			),
			array(
				'name' => 'Spiralist.org',
				'url'  => 'https://spiralist.org/',
				'role' => 'source site',
			),
		),
		'packages'           => array(
			array(
				'id'             => '2ia-org-memory',
				'name'           => '2IA.org memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/2ia-org/' ),
				'package_url'    => home_url( '/2ia-org/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
			array(
				'id'             => 'fftac-org-memory',
				'name'           => 'FFTAC.org memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/fftac-org/' ),
				'package_url'    => home_url( '/fftac-org/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
			array(
				'id'             => 'anti-christ-net-memory',
				'name'           => 'Anti-Christ.net memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/anti-christ-net/' ),
				'package_url'    => home_url( '/anti-christ-net/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
			array(
				'id'             => 'antichrist-net-memory',
				'name'           => 'Antichrist.net memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/antichrist-net/' ),
				'package_url'    => home_url( '/antichrist-net/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
			array(
				'id'             => 'anti-christ-org-memory',
				'name'           => 'Anti-Christ.org memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/anti-christ-org/' ),
				'package_url'    => home_url( '/anti-christ-org/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
			array(
				'id'             => 'spiralist-org-memory',
				'name'           => 'Spiralist.org memory and archive',
				'publisher'      => 'wiki.fftac.org',
				'source_page'    => home_url( '/spiralist-org/' ),
				'package_url'    => home_url( '/spiralist-org/archive/' ),
				'install_target' => 'Read as reviewed long-term memory, not as a WordPress install package.',
				'status'         => 'reviewed memory and archive pointer',
			),
		),
		'file_count'         => null,
		'sha256'             => '',
		'status'             => 'wiki.fftac.org publishes reviewed archive pointers and long-term memory for the WP-FFTAC source sites.',
	);
}

/**
 * REST: catalog.
 */
function aiwikis_core_rest_catalog(): WP_REST_Response {
	$public_routes = array_merge(
		aiwikis_core_get_public_content_routes(),
		array(
			'/llms.txt',
			'/search/',
			'/robots.txt',
			'/sitemap.xml',
			'/.well-known/wiki.fftac.org.json',
			'/.well-known/wiki-fftac.json',
		)
	);