# Plugin Patterns

> The Aegis plugin registers block patterns from patterns/ when loaded. Always-on patterns use config/patterns.php; WooCommerce and wishlist patterns use config/woocommerce-patterns.php with dependency gates.

## Pattern Directories

![The block inserter's Patterns tab showing pattern categories added by the Aegis plugin, with previews of commerce patterns.](https://www.atmostfear-entertainment.com/wp-content/uploads/2026/11/plugin-patterns.png)

*Patterns added by the plugin in the block inserter.*

| Directory | Patterns | When registered |
| --- | --- | --- |
| `patterns/slider/` | Slider demonstration patterns | Slider block implied on |
| `patterns/modal/` | Modal starters (`modal-video`, `modal-newsletter`, `modal-contact`, `modal-cookie-consent`) | Modal block enabled (`config/patterns.php`) |
| `patterns/contact/` | Contact form layouts (includes Map block) | Plugin + theme active |
| `patterns/author/` | Co-authors layout patterns | Co-Authors Plus active **and** the integration on |
| `patterns/woocommerce/` | Shop templates, product layouts, WC headers, checkout/cart patterns | **WooCommerce active** |
| `patterns/wishlist/` | Wishlist page pattern (`template-page-wishlist`) | **WooCommerce + TI Wishlist active** |

## Dependency Matrix

| Pattern set | Requires |
| --- | --- |
| Slider | Aegis theme + Aegis plugin + Slider extras implied on |
| Modal patterns | Above + Modal block enabled |
| Map contact patterns | Above + Map block enabled |
| `patterns/author/` | Co-Authors Plus active **and** the integration on |
| `patterns/woocommerce/**` | Above + **WooCommerce** |
| `patterns/wishlist/**` | Above + **TI WooCommerce Wishlist** |

Commerce patterns use the same slug convention as theme patterns (`template-page-cart`, `header-default`, etc.) via `\Aegis\Utilities\Pattern::register_from_file()` so FSE templates that reference pattern slugs continue to resolve.

The theme does **not** ship copies of those WooCommerce patterns. The exception is a Woo-free `header/default` for `parts/header.html` when WooCommerce is inactive; the plugin overlays the mini-cart variant of `header-default` when WooCommerce is active.

**FSE templates** (cart, checkout, wishlist, etc.) remain in the **theme** `templates/` directory. They are hidden from the Site Editor when dependencies are inactive; companion patterns register only when dependencies are active.

Generic commerce marketing patterns without WooCommerce blocks (trust badges, category grids with core blocks) stay in the theme.

### Bookshop Patterns

Added in 1.0.2. They register with the other WooCommerce patterns (WooCommerce active). Slugs follow the first category plus the file’s `Slug` header.

| Pattern | Slug | Use |
| --- | --- | --- |
| Book Buy Box | `product-book-buy` | Single product buy box for a book |
| Related Novels | `product-book-related` | Related products under a book |
| Bookshop Catalog (Shop) | `product-archive-live` | Live product grid |
| Selected Works (Shop) | `product-works-live` | Live product grid |
| Author’s Desk (Shop) | `product-desk-live` | Live product grid |
| Journal Edition (Shop) | `product-journal-live` | Live product grid |
| Journal Shop Sidebar | `sidebar-journal-shop` | Shop sidebar |
| Catalog Store Header | `header-store-catalog` | Store header with search, customer account, and mini cart |
| Bookshop Store Header | `header-store-bookshop` | Store header with search, customer account, and mini cart |
| Author Shop Page | `pages-author-store` | Full page |
| Book Product Page | `pages-book-store` | Full page |
| Journal Shop Page | `pages-journal-store` | Full page |
| Coastline Essay, Shop | `pages-essay-store` | Full page |
| Bookshop, Shop | `pages-bookshop-store` | Full page |
| Archival Checkout, Shop | `pages-checkout-store` | Full page |
| Bindery Confirmation, Shop | `pages-confirmation-store` | Full page |

## CommercePatternRegistrar

`src/Patterns/CommercePatternRegistrar.php` (`config/woocommerce-patterns.php`):

- Hooks `init` at **priority 12** (after the theme unregisters `woocommerce/` plugin patterns at priority 11)
- **`is_woocommerce_active()`** — `WooCommerce::is_plugin_active()` (`WooCommerce`, `WC()`, or `WC_VERSION`)
- **`is_ti_wishlist_active()`** — `defined( 'TINVWL_VERSION' )` or `function_exists( 'tinvwl_get_wishlist' )`
- Recursively scans `patterns/woocommerce/` when WooCommerce is active
- Scans `patterns/wishlist/` when both WooCommerce and TI Wishlist are active
- Skips dot-prefixed PHP files; registers via `\Aegis\Utilities\Pattern::register_from_file()` for slug parity with theme FSE templates

## Pattern audit

The theme tool `tools/audit-patterns.php` scans plugin `patterns/woocommerce/` and `patterns/wishlist/` for slug integrity. See [Theme Development Tools](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/tools/).

## Pro Patterns

Marketing and premium layout patterns live in **Aegis Pro**. See [Pro Patterns](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/).

Do not duplicate Pro pattern slugs in the theme or free plugin.

Contact form+map layouts (`form-map`, `form-map-overlay`) live in this plugin and register only when the Map block is enabled. Do not copy them into the theme.

The contact patterns (`aegis/form-map`, `aegis/form-map-overlay`, `aegis/modal-contact`) hold a static HTML form that only shows the layout. Keep them free of add-on code. While the Aegis Forms add-on is active, it registers its own versions under the same names, with a working Form block; when it is deactivated these files are used again.

Modal starters live **only** in this plugin (`patterns/modal/`, names `aegis/modal-*`). They register when **Aegis → Blocks → Modal** is enabled. Do not ship or draft them under the theme `patterns/modal/` folder.

Related Posts grid, list, cards, and minimal layouts live in the **theme** (`patterns/blog/related-posts-*.php`, slugs `blog-related-posts-*`). They unregister when **Aegis → Blocks → Related Posts** is implied off. Do not copy them into this plugin.

## Next Steps

- [Theme Block Patterns](https://www.atmostfear-entertainment.com/docs/aegis/themes/theme/block-patterns/)
- [Pro Patterns](https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/)

---

Source: https://www.atmostfear-entertainment.com/docs/aegis/plugins/dash/plugin-patterns/ · Updated 2026-11-22
