# Architecture

> Technical architecture of the Aegis companion plugin.

## Bootstrap

`aegis.php` defines constants (`DIR`, `FILE`, `VERSION`, `MIN_THEME_VERSION`) and loads the plugin’s own PSR-4 autoloader, `src/autoload.php`. It does not use Composer at runtime. It then requires `config/updater.php`, which starts the plugin updater. This happens **before** the theme check, so updates still work without the Aegis theme.

Next, the plugin checks that the Aegis theme is active. Without it, bootstrap stops there and an admin notice is shown. If the theme is older than `MIN_THEME_VERSION` (1.0.0), the plugin still loads but shows a notice recommending an update.

With the theme active, the feature configs load in this order:

```
config/coauthors.phpconfig/map.phpconfig/analytics.phpconfig/blocks.php / blocks-registrar.phpconfig/modal.phpconfig/injection.php (requires injection-integrations.php)config/hooks.phpconfig/snippets.phpconfig/visibility-presets.phpconfig/license.phpconfig/conditionals.php / conditionals-renderer.phpconfig/integrations.phpconfig/connectors.phpconfig/seo.phpconfig/admin.phpconfig/admin-shell.phpconfig/editor.phpconfig/performance.phpconfig/woocommerce.phpconfig/patterns.phpconfig/woocommerce-patterns.phpconfig/activation-redirect.php
```

`config/license.php` registers the free **License** (Get Pro) page on `after_setup_theme`. The page is skipped when Aegis Pro is installed, because Pro replaces it with its license screen on the same `aegis-license` slug.

`aegis.php` also loads the plugin text domain (`aegis`) from `languages/` on `init`. Plugin UI strings ship in `languages/aegis.pot`. They are not merged into the theme POT. See [Building Assets](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/building-assets-2/#translations).

## Namespace

- **Package namespace:** `Aegis\Plugin\`
- **Mapped to:** `src/`

## Module Overview

| Module | Responsibility |
| --- | --- |
| `Admin/` | Menu, Renderer, AdminTabs, UI (shared admin kit helpers), the updater (native WordPress updates from the `aegis.zip` package of the latest release; repository filterable with `aegis_plugin_update_repository`) |
| `Analytics/` | Tracker, Connectors panel, Settings |
| `Blocks/` | Registrar, AdminPage, SettingsController, VideoSchema, and Settings. `Blocks\Settings` owns the whole `aegis_blocks` option: every block feature toggle (theme blocks, plugin blocks, and core block extensions such as Query Loop) plus the **Aegis → Performance** keys (`embed_facades`, `perf_*`) |
| `Conditionals/` | Evaluator, AdminPage, PostContentRenderer, SmartConditionsEvaluator, IntegrationsPanel (plugin extras on **Aegis → Integrations**). Posts and hook patterns share `should_render_conditions()`. User extras include status, role, capability (`current_user_can` on a normalized slug), specific users, and Pro user meta. Schedule extras parse naive datetimes with `DateTimeImmutable` in an IANA zone (or the site timezone); non-IANA saved zones fall back to the site timezone. Image Source extras are Pro (`AegisPro\Query\ImageSource`). Viewport/a11y classes go on the existing post-content root (`Visibility::apply_classes()`); hook patterns wrap (`Visibility::wrap()`). |
| `Connectors/` | Connectors admin (BunnyCDN, Maps, Analytics panels) |
| `General/` | General settings admin (data removal) |
| `Hooks/` | Hook patterns admin (instance list) |
| `VisibilityPresets/` | Visibility presets admin (library list; CRUD requires Pro) |
| `Injection/` | LocationRegistry, Preview, IntegrationInjector (including Co-Authors Plus wrap of `core/post-author` and `co-authors/block`) |
| `CoAuthors/` | Multi-author `core/post-author*` replace, optional Author Schema extra |
| `Integrations/` | Registry, AdminPage, Settings, Notices, WPFusion (catalog pickers, list membership, CRM login, plugin detection), ACF (plugin detection and parent gating, including Secure Custom Fields), MetaBox (`RWMB_Loader` / `rwmb_meta()`, including AIO), CodeBlockPro (`CBPRouter` / `kevinbatdorf/code-block-pro` detection), SyntaxHighlighting (`Syntax_Highlighting_Code_Block\PLUGIN_VERSION` / `boot()`), AffiliateWP (`Affiliate_WP` / `affiliate_wp()` / `AFFILIATEWP_VERSION`), EasyDigitalDownloads (`Easy_Digital_Downloads` / `EDD()` / `EDD_VERSION`), FluentBooking (`FluentBooking.php` helper: `FLUENT_BOOKING_VERSION` / `FluentBooking\App\App`, plus `is_enabled()`), FluentForms (`FluentForms.php` helper: `FLUENTFORM` / `FLUENTFORM_VERSION` / `FluentForm\App\Modules\Form\Form`, plus `is_enabled()`), GravityForms (`GravityForms.php` helper: `GFForms` / `GFAPI` / `GF_MIN_WP_VERSION` / `gravity_form()`, plus `is_enabled()`), NinjaForms (`NinjaForms.php` helper: `Ninja_Forms` / `NF_PLUGIN_VERSION` / `NF_VERSION`, plus `is_enabled()`), LearnDash (`LearnDash.php` helper: `LEARNDASH_VERSION` / `SFWD_LMS` / `LEARNDASH_LMS_PLUGIN_DIR` / `learndash_init()`, plus `is_enabled()`), WooCommerce (`WooCommerce.php` helper: `WooCommerce` / `WC()` / `WC_VERSION`, plus `is_enabled()`), `WooCommerce\MultiStepCheckout` (assets on the multi-step template when the integration is on) |
| `Map/` | Map block, Google Maps connectors panel, Static Maps style encoding |
| `Modal/` | Modal block, instance scanner, Modals admin |
| `Seo/` | SEO Manager and plugin adapters |
| `Settings/` | Repository, Controller (AJAX export/import), Migration |
| `Snippets/` | Manager, Storage, Loader, Executors |
| `Patterns/` | `CommercePatternRegistrar` — gated WooCommerce and wishlist patterns |
| `Performance/` | FrontendOptimizations, Performance admin page |
| `License/` | `AdminPage`: free **License** / Get Pro screen (`aegis-license`), registered only when Aegis Pro is inactive |
| `Utilities/` | `UserAgent`: device and browser matching for conditional logic rules |

## CommercePatternRegistrar

See [Plugin Patterns — CommercePatternRegistrar](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/plugin-patterns-2/#commercepatternregistrar) for dependency checks, init priority, and slug registration.

## Block Registration Model

| Layer | Registers |
| --- | --- |
| **Theme** | None once the removal release ships. Until then the theme registers the six blocks below only when the plugin has not. |
| **Plugin** | `aegis/countdown`, `slider`, `slide`, `toggle`, `toggle-content`, `related-posts` (`Blocks\ThemeBlocksRegistrar`), `aegis/map`, `aegis/modal` (+ admin, `core/video` editor extensions) |
| **Pro** | `aegis/tabs`, `tab`, `image-compare` (`src/Blocks/image-compare`); attribute extensions on theme blocks, plugin blocks, `core/video`, and `core/query` |

Video is **`core/video`**, not `aegis/video`.

## Framework Dependency

The plugin reads and writes settings via `Settings\Repository`. The Aegis framework (`vendor/aegis/framework` in the theme) reads these settings for:

- Integration CSS loading
- Block feature enablement (`is_block_enabled()`), including Group Marquee extras
- Schema delegation checks

## Relationship to Theme and Pro

| Layer | Role |
| --- | --- |
| Theme | Registers six custom blocks, FSE assets, framework bootstrap, `core/video` enhancements |
| Free plugin | Settings, admin, map/modal, snippets, conditionals, analytics, `core/video` editor scripts, **gated commerce patterns** |
| Pro | Hook pattern CPT, video stack on `core/video`, query pro on `core/query`, Pro-only blocks, block extensions, license |

## Next Steps

- [Building Assets](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/building-assets/) — Build commands and translations
- [File Structure](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/file-structure/) — Directory layout
- [Theme Architecture](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/architecture/)

---

Source: https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/architecture/ · Updated 2026-11-25
