# Architecture

> Technical architecture of the Aegis theme and its relationship to the framework and Aegis plugins.

## Four-Layer Model

| Layer | Location | Responsibility |
| --- | --- | --- |
| **Theme** | `wp-content/themes/aegis` | FSE templates, generic theme patterns (excluding WC/TI block patterns), fallback copies of the six Aegis blocks (until a later release removes them), thin PHP glue |
| **Framework** | `vendor/aegis/framework` | Core block enhancements, variations, design system engine, injection hook firing |
| **Aegis Dash** | `wp-content/plugins/aegis-dash` | Admin, the Aegis blocks (Map, Modal, Slider, Toggle, Countdown, Related Posts), snippets, conditionals, integrations, analytics, **WooCommerce/TI Wishlist block patterns** (gated) |
| **Pro plugin** | `wp-content/plugins/aegis-pro` | Hook pattern CPT, video stack, query pro, license, Pro patterns |

## Template gating

FSE **templates** remain in the theme (`templates/` + `theme.json`). WooCommerce and wishlist templates are **hidden from the Site Editor template picker** when dependencies are inactive via `vendor/aegis/framework/src/DesignSystem/Templates.php` (`get_block_templates` filter). See [Template Reference](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/template-reference/).

## Theme Overview

- **PSR-4 autoloading** via Composer — namespace `Aegis\` mapped to `src/` (theme glue + blocks)
- **Framework bootstrap** — `Aegis::register()` from `vendor/aegis/framework`
- **Theme services** — `CompanionNotice`, `GitHubUpdater`, `BlockRegistrar` (fallback copies of the Aegis blocks from `blocks-manifest.php`, registered only when Aegis Dash has not registered them; Related Posts and Slider extras localization, Related Posts pattern gating), `NavigationFallback`, and `PatternDependencies` (hides patterns whose blocks need an inactive plugin, and strips them from headers, when the editor loads patterns), all started in `src/bootstrap.php`

## Namespace Structure (`src/`)

```
src/├── bootstrap.php              # Composer files autoload — starts the theme services below├── helpers.php                # Pattern URL helpers (required from functions.php)├── NavigationFallback.php     # block_core_navigation_render_fallback: sample menu instead of every page├── PatternDependencies.php    # rest_pre_dispatch (patterns endpoint): hide patterns with blocks from inactive plugins├── Admin/│   ├── CompanionNotice.php    # Install Aegis Dash notice (release zip)│   └── GitHubUpdater.php      # update_themes_github.com: updates from GitHub releases└── Blocks/                    # block.json + TSX sources (compiled in place)    ├── BlockRegistrar.php    ├── RelatedPostsQuery.php    ├── ToggleId.php           # Stable data-toggle-id for Toggle    └── blocks-manifest.php    # Generated by npm run build
```

## Framework (`vendor/aegis/framework`)

Registered via `ServiceProvider` when `Aegis::register()` runs:

- 37+ core block render filters (`CoreBlocks\`), including `core/icon` and Lightbox extras
- Icon library registration (`Icons\Library`) on WordPress 7.1+; `wp aegis migrate-icons` for leftover Image icons
- Block settings (Visibility, Animation, Query enhancements, …). Visibility viewport/a11y extras add CSS classes to the block or post-content root; hook patterns wrap. Color Scheme follows `is-style-*` and `default-mode-*` on `body`.
- Block variations (Accordion, Counter, Marquee, Newsletter, SVG Image — not Image Icon). Marquee extras are gated at **Aegis → Blocks → Marquee**. Accordion, Newsletter, and SVG styles register once in PHP (`register_style()`), not via `BlockStyles`. The SVG inspector is `svg-editor.js` (no SVGOMG Optimize control).
- Design system (Patterns scanner, REST trim, template pattern expander, dynamic template parts, DarkMode, SkipLink, BlockStyles for decorative styles such as surface/checklist, EditorAssets, navigation overlay, editor overlay fix)
- Integration CSS (gated by plugin settings when the plugin is active), including Meta Box form styling (`plugins/meta-box.css`), Easy Digital Downloads download/checkout styling (`plugins/edd/edd.css`), AffiliateWP Affiliate Area and login/register form styling (`plugins/affiliate-wp.css`), Fluent Forms form element and button styling (`plugins/fluent-forms.css`, injected on `fluentform` / `ff_form` / `fluent_form` / `fluent-form` / `ff-form`), Fluent Booking calendar and appointment styling (`plugins/fluentbooking.css`, injected on `fluent-booking` / `fcal_` / `fcal-` / `fluentbooking`), Gravity Forms form element, input, and button styling (`plugins/gravity-forms.css`, injected on `gform_wrapper` / `gravity-theme` / `gform` / `gform_body` / `gform-body` / `gfield`), WooCommerce shop/cart/checkout styling (`plugins/woocommerce/woocommerce.css`) and breadcrumbs (`plugins/woocommerce/woocommerce-breadcrumbs.css`, injected on `woocommerce-breadcrumb` / `wc-block-breadcrumbs` / `wp-block-woocommerce-breadcrumbs`). Classic and Store Breadcrumb delimiters wrap in `.aegis-breadcrumb-separator` (`woocommerce_breadcrumb_defaults` and `render_block_woocommerce/breadcrumbs`). Also the Code Block Pro overlay (`plugins/code-block-pro.css`), and the Syntax Highlighting Code Block overlay (`plugins/syntax-highlighting-code-block.css`, injected on `hljs` / `shcb-`)
- Injection hook firing on template parts and post content

## Bootstrap Flow

### 1. functions.php

Loads Composer autoload, helpers, textdomain, and `Aegis::register()`.

### 2. src/bootstrap.php

Initializes `CompanionNotice`, `GitHubUpdater`, `BlockRegistrar`, `NavigationFallback`, and `PatternDependencies`. Adds `style.css` as an editor style. Icon packs under `vendor/aegis/icons/public/icons/` (including `payment`) are discovered automatically.

### 3. Aegis::register()

Boots the framework ServiceProvider (design system, core blocks, integrations).

## What Moved to Plugins

These features are **not** in theme PHP — see plugin docs:

| Feature | Documentation |
| --- | --- |
| Analytics | [Aegis Dash Analytics](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/analytics/) |
| Conditionals admin/evaluator | [Conditional Logic](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/conditional-logic/) |
| Admin dashboard | [Aegis Dash Architecture](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/architecture/) |
| Multi-step checkout | [WooCommerce Checkout](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/woocommerce-checkout/) |
| Integrations dashboard | [Integrations Dashboard](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/integrations-dashboard/) |
| Hook pattern CPT | [Pro Hook Patterns](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/) |
| Map / Modal blocks | [Aegis Dash Custom Blocks](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/custom-blocks/) |

## Build Pipeline

Dual build — see [Building Assets](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/building-assets/):

- **Theme:** `npm run build` → compiled assets in `src/Blocks/` (the theme’s fallback copies of the six blocks)
- **Aegis Dash:** `npm run build` in `wp-content/plugins/aegis-dash` (admin app and the six TypeScript blocks; Map and Modal are hand-maintained)

## Next Steps

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

---

Source: https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/architecture/ · Updated 2026-11-24
