Skip to content
wiki.fftac.org

Class Uai1 Plugin

**Site relevance:** Spiralist.org

**Memory type:** plugin source memory

**Source path:** Spiralist/wp-content/plugins/uai-1-wordpress/includes/class-uai1-plugin.php

**Size:** 1.5 KB

Summary

if (!defined('ABSPATH'))

Source Preview

This source file is short enough to preview directly on its source-memory page.

<?php

if (!defined('ABSPATH')) {
    exit;
}

class UAI1_Plugin
{
    public function init(): void
    {
        UAI1_Membership::init();
        UAI1_Agents::init();
        UAI1_Participant_Admin::init();

        add_action('init', [UAI1_Routes::class, 'register_rewrite_rules'], 99);
        add_action('rest_api_init', [UAI1_Routes::class, 'register_rest_routes']);
        add_action('rest_api_init', [UAI1_Memory_Checkpoints::class, 'register_rest_routes']);
        add_action('rest_api_init', [UAI1_Project_Handoff::class, 'register_rest_routes']);
        add_filter('query_vars', [UAI1_Routes::class, 'register_query_vars']);
        add_action('template_redirect', [UAI1_Routes::class, 'handle_uai1_request']);

        add_action('wp_head', [UAI1_Head_Links::class, 'render_alternate_link']);
        add_action('send_headers', [UAI1_Head_Links::class, 'send_alternate_header']);

        add_action('init', [$this, 'maybe_refresh_rewrite_rules'], 100);
    }

    public function maybe_refresh_rewrite_rules(): void
    {
        $installed_version = (string) get_option('uai1_wp_plugin_version', '');
        if ($installed_version === UAI1_WP_VERSION) {
            return;
        }

        UAI1_Membership::install();
        UAI1_Agents::install();
        UAI1_Usage_Log::install();
        UAI1_Routes::register_rewrite_rules();
        flush_rewrite_rules(false);
        update_option('uai1_wp_plugin_version', UAI1_WP_VERSION, false);
    }
}