wiki.fftac.org Core - Source Excerpt 01
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
<?php
/**
* Plugin Name: wiki.fftac.org Core
* Plugin URI: http://wiki.fftac.org/
* Description: wiki.fftac.org publication primitives for reviewed WP-FFTAC long-term memory, archive pages, REST discovery, and shortcodes.
* Version: 3.29.0
* Requires at least: 6.5
* Requires PHP: 8.1
* Author: wiki.fftac.org
* Author URI: http://wiki.fftac.org/
* Text Domain: aiwikis-core
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* @package AIWikisCore
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'str_contains' ) ) {
function str_contains( string $haystack, string $needle ): bool {
return '' === $needle || false !== strpos( $haystack, $needle );
}
}
if ( ! function_exists( 'str_starts_with' ) ) {
function str_starts_with( string $haystack, string $needle ): bool {
return '' === $needle || 0 === strpos( $haystack, $needle );
}
}
if ( ! function_exists( 'str_ends_with' ) ) {
function str_ends_with( string $haystack, string $needle ): bool {
if ( '' === $needle ) {
return true;
}
$length = strlen( $needle );
return 0 === substr_compare( $haystack, $needle, -$length );
}
}
define( 'AIWIKIS_CORE_VERSION', '3.29.0' );
define( 'AIWIKIS_CORE_PLUGIN_FILE', __FILE__ );
define( 'AIWIKIS_CORE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AIWIKIS_CORE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
/**
* Return the local project root when running from this source tree.
*/
function aiwikis_core_project_root(): string {
return dirname( AIWIKIS_CORE_PLUGIN_DIR, 3 );
}
/**
* Register post types, taxonomies, metadata, REST routes, shortcodes, and rewrites.
*/
function aiwikis_core_init(): void {
aiwikis_core_register_post_types();
aiwikis_core_register_taxonomies();
aiwikis_core_register_meta();
aiwikis_core_register_shortcodes();
aiwikis_core_register_rewrite_rules();
}
add_action( 'init', 'aiwikis_core_init' );
/**
* Register wiki.fftac.org post types.
*/
function aiwikis_core_register_post_types(): void {
$types = array(
'aiwiki_topic' => array(
'singular' => __( 'AIWiki Topic', 'aiwikis-core' ),
'plural' => __( 'AIWiki Topics', 'aiwikis-core' ),
'slug' => 'topics',
'menu' => 'dashicons-welcome-learn-more',
),
'aiwiki_source' => array(
'singular' => __( 'AIWiki Source', 'aiwikis-core' ),
'plural' => __( 'AIWiki Sources', 'aiwikis-core' ),
'slug' => 'sources',
'menu' => 'dashicons-media-document',
),
'aiwiki_pack' => array(
'singular' => __( 'AIWiki Source Package', 'aiwikis-core' ),
'plural' => __( 'AIWiki Source Packages', 'aiwikis-core' ),
'slug' => 'source-packages',
'menu' => 'dashicons-download',
),
'aiwiki_release' => array(
'singular' => __( 'AIWiki Release', 'aiwikis-core' ),
'plural' => __( 'AIWiki Releases', 'aiwikis-core' ),
'slug' => 'releases',
'menu' => 'dashicons-archive',
),
);
foreach ( $types as $post_type => $args ) {
register_post_type(
$post_type,
array(
'labels' => array(
'name' => $args['plural'],
'singular_name' => $args['singular'],
'add_new_item' => sprintf(
/* translators: %s: content type singular name. */
__( 'Add New %s', 'aiwikis-core' ),
$args['singular']
),
'edit_item' => sprintf(
/* translators: %s: content type singular name. */
__( 'Edit %s', 'aiwikis-core' ),
$args['singular']
),
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => $args['menu'],
'rewrite' => array( 'slug' => $args['slug'] ),
'supports' => array( 'title', 'editor', 'excerpt', 'revisions', 'custom-fields' ),
)
);
}
}
/**
* Register wiki.fftac.org taxonomies.
*/
function aiwikis_core_register_taxonomies(): void {
$post_types = array( 'post', 'page', 'aiwiki_topic', 'aiwiki_source', 'aiwiki_pack', 'aiwiki_release' );
$taxonomies = array(
'aiwiki_trust_status' => array(
'label' => __( 'Trust Status', 'aiwikis-core' ),
'slug' => 'trust-status',
'terms' => array(
'authoritative',
'reviewed',
'working-draft',
'proposal',
'needs-review',
'historical',
'deprecated',
'external-reference',
),
),
'aiwiki_source_role' => array(
'label' => __( 'Source Role', 'aiwikis-core' ),
'slug' => 'source-role',
'terms' => array(
'canonical',
'handbook',
'starter',
'adoption-kit',
'conformance',
'implementation',
'reference',
'observation',
),
),
'aiwiki_audience' => array(
'label' => __( 'Audience', 'aiwikis-core' ),
'slug' => 'audience',
'terms' => array(
'humans',
'ai-agents',
'maintainers',
'implementers',
'reviewers',
),
),
);
foreach ( $taxonomies as $taxonomy => $args ) {
register_taxonomy(
$taxonomy,
$post_types,
array(
'label' => $args['label'],
'hierarchical' => false,
'public' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'rewrite' => array( 'slug' => $args['slug'] ),
)
);
}
}
/**
* Register metadata fields for pages, posts, and wiki.fftac.org post types.
*/
function aiwikis_core_register_meta(): void {
$post_types = array( 'post', 'page', 'aiwiki_topic', 'aiwiki_source', 'aiwiki_pack', 'aiwiki_release' );
$fields = array(
'owner',
'status',
'trust_level',
'source_status',
'source_url',
'source_name',
'last_reviewed',
'review_cycle',
'audience',
'sensitivity',
'agent_use',
'related_paths',
'source_sha256',
'source_fetched_at',
'uai_id',
'confidence',
'lineage',
);
foreach ( $post_types as $post_type ) {
foreach ( $fields as $field ) {
register_post_meta(
$post_type,
"_aiwikis_{$field}",
array(
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => 'sanitize_text_field',
'auth_callback' => static function (): bool {
return current_user_can( 'edit_posts' );
},
)
);
}
foreach ( array( 'human_review_required_for_updates', 'citation_required' ) as $field ) {
register_post_meta(
$post_type,
"_aiwikis_{$field}",
array(
'type' => 'boolean',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => 'rest_sanitize_boolean',
'auth_callback' => static function (): bool {
return current_user_can( 'edit_posts' );
},
)
);
}
}
}
/**
* Add default taxonomy terms once taxonomies exist.
*/
function aiwikis_core_ensure_terms(): void {
$terms = array(
'aiwiki_trust_status' => array(
'authoritative',
'reviewed',
'working-draft',
'proposal',
'needs-review',
'historical',
'deprecated',
'external-reference',
),
'aiwiki_source_role' => array(
'canonical',
'handbook',
'starter',
'adoption-kit',
'conformance',
'implementation',
'reference',
'observation',
),
'aiwiki_audience' => array(
'humans',
'ai-agents',
'maintainers',
'implementers',
'reviewers',
),
);
foreach ( $terms as $taxonomy => $slugs ) {
foreach ( $slugs as $slug ) {
if ( ! term_exists( $slug, $taxonomy ) ) {
wp_insert_term( ucwords( str_replace( '-', ' ', $slug ) ), $taxonomy, array( 'slug' => $slug ) );
}
}
}
}
add_action( 'init', 'aiwikis_core_ensure_terms', 20 );
/**
* Register REST routes.
*/
function aiwikis_core_register_rest_routes(): void {
register_rest_route(
'wiki.fftac.org/v1',
'/catalog',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'aiwikis_core_rest_catalog',
'permission_callback' => '__return_true',
)
);
register_rest_route(
'wiki.fftac.org/v1',
'/source-map',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'aiwikis_core_rest_source_map',
'permission_callback' => '__return_true',
)
);
register_rest_route(
'wiki.fftac.org/v1',
'/source-packages',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'aiwikis_core_rest_source_packages',
'permission_callback' => '__return_true',
)
);
register_rest_route(
'wiki.fftac.org/v1',
'/llms',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'aiwikis_core_rest_llms',
'permission_callback' => '__return_true',
)
);
register_rest_route(
'wiki.fftac.org/v1',
'/search-index',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'aiwikis_core_rest_search_index',
'permission_callback' => '__return_true',
)
);