Admin: Aegis → Code Snippets (admin.php?page=aegis-snippets)
The screen uses the shared Aegis admin layout. Snippets and Settings tabs sit at the top left (Settings is &tab=settings, also reached from the top bar Settings link). Add Snippet is at the top right, and on the Snippets tab Tools next to it has Export Snippets (every snippet and its code as a .json file) and Import Snippets (adds snippets from such a file).
Storage
Snippets are stored in uploads/aegis-snippets/ (not in the database export bundle).
Snippet Types
Pick a type first. The editor and run locations follow that type.
| Type | Runs as | Default locations |
|---|---|---|
| Functions (PHP) | Included like functions.php (requires PHP opt-in) |
Everywhere, frontend, admin, login, or a custom injection hook |
| Content | HTML, or mixed PHP + HTML when PHP is enabled | Site header, body open, footer, before/after content, shortcode, or a custom hook |
| CSS | Enqueued stylesheet | Frontend, admin, login, or block editor |
| JavaScript | Enqueued script | Frontend/admin header or footer, login, or block editor |
Existing html snippets are treated as Content. CSS/JS snippets that stored a generic hook name are migrated to the type-aware locations above.
Snippet Editor
The edit screen is code-first:

Edit a snippet’s code, type, and location.
- The top row has Snippets (back to the list), the type tabs, the Enabled switch, Cancel, and Create Snippet or Update Snippet. The Title field sits under it.
-
Type tabs switch syntax highlighting, linting, location list, and a starter template (
<?php, content comments, CSS, or a JS IIFE). A line beside the Code label says what the selected type does. - Dark CodeMirror editor with language badge, Format, HTML/CSS/JS lint, and PHP
php -lchecks - Where to Run uses a dropdown plus a title/description catalog under the editor. Content locations list Shortcode, header, body open, and footer full-width, then Before/After content side by side. Custom injection hooks stay in the dropdown only.
- Conditions sits under the location chooser
- The Snippet card on the right holds group, priority, tags, and description. Early, Default, and Late set the priority to 5, 10, or 50 in one click, and the description counts up to 240 characters.
- Fullscreen (beside Format) gives the code the whole window; Esc closes it.
- Ctrl+S (Cmd+S on a Mac) saves the snippet, and leaving with unsaved changes asks first.
- Revisions (on an existing snippet) lists the last ten earlier versions of the code. Restore loads one into the editor; press Update Snippet to keep it.
Search, Export, and Import stay on the snippets list, not the editor. Global settings and the custom-location catalog live on the Settings tab.
Pasting code that looks like another language suggests switching type. The type tab remains the source of truth.
Snippet Library
Library, in the code bar of the snippet editor (on a new snippet and when you edit one), opens a searchable list of ready-made snippets taken from this documentation. Pick one and it loads into the editor, switches to the right type, and fills in the title if it is empty. If you have already written code, Aegis asks before replacing it.

The Snippet Library.
The Library is grouped by where each snippet comes from:
- Aegis Dash and Aegis Theme: hooks for schema, dark mode, template parts, assets, and more.
- WooCommerce, Yoast SEO, and Gravity Forms: shown only while that plugin is active.
- Aegis Ads, Aegis Docs, Aegis Forms, and Aegis Pro: each add-on adds its own group while it is active.
The Library only has snippets that change how your site behaves. Developer hooks for building on Aegis (adding admin tabs, notices, or screens, and changing update sources) stay in the Code Snippets Reference. It also never includes anything that an Aegis toggle already does, such as removing emoji scripts, which is on Aegis → Performance. An add-on can add its own group with the aegis_snippet_library filter. See Code Snippets Reference.
Shortcodes
Set a Content snippet’s run location to Shortcode. It no longer runs on its own. Place it with:
Copied!HTML[ aegis_snippet id="6-office-hours-notice" ]
The id is the snippet filename without the extension. It is derived from the title the first time you save, and does not change if you rename the snippet later. Save once, then copy the shortcode from the editor (copy button next to the tag).
Attributes you add are available inside PHP Content snippets as $atts. Enclosed content is $content. The snippet may print markup or return a string/number; printed output wins. If it produces nothing valid, users who can manage_options see a short error and everyone else sees nothing.
Conditional logic is evaluated when the shortcode renders. Legacy per-snippet tags such as [aegis_abc123] still work if they were already stored.
Groups and list filters
Each snippet can have an optional group (virtual folder) and tags. The list supports code snippets organization:

The snippets list with group filters.
- Type filters with counts (All, Functions (PHP), Content, CSS, JavaScript) under the Your snippets heading
- Search snippets across name, description, tags, and group, a tag filter, sort, and Hide inactive (remembered in the browser)
- Grouped and Table views at the top right of the card (remembered in the browser); click a group to fold it
- Sort by name, created, updated, or priority
- Columns follow the same order on every Aegis list: Name, Description, Type, Runs At, Tags, Status, and Last Modified. Name, Status, and Last Modified sort when you click their headings.
- Each row ends with the status switch, Edit, a duplicate button (the copy is saved disabled, as “Title (Copy)”), a download button (JSON), and a delete button. Switching a snippet on or off shows a notice at the top of the screen, green when it worked and red when it failed.
- Status is Active (green) or Disabled (grey). Snippets paused after a fatal error show Paused (red) with the error in the description column.
Conditional logic on the editor is off by default. Turn on Enable Conditional Logic to build AND groups separated by OR. Page / Post Type is always available. Logged-in, role (from the site’s role list), capability (typed slug such as edit_posts; is / is not only), URL, query string, and WP Fusion tag/list/CRM-logged-in fields appear only when their extras are on at Aegis → Conditionals or Integrations. Viewport, accessibility, and Schedule extras are not on the snippet editor (Schedule is a dedicated extras UI on blocks, posts, and hook patterns). See Conditional Logic.
PHP Snippets and Safe Mode
It is a dedicated section on Aegis → Code Snippets → Settings.
| Setting | Description |
|---|---|
| PHP snippets | Master switch for PHP snippet execution |
| Auto Safe Mode on fatal error | Enable Safe Mode automatically when a PHP snippet fatals |
| Enable Safe Mode | Disable all snippets and hook pattern output site-wide |
| Safe Mode URL | Secret ?aegis_safe_mode=TOKEN link that turns Safe Mode on without logging in. Copy and Regenerate sit next to the URL. |
AEGIS_DISABLE_SNIPPETS |
define( 'AEGIS_DISABLE_SNIPPETS', true ); in wp-config.php when HTTP is unreachable |
Visiting the Safe Mode URL enables it and redirects to Snippets Settings (login if needed). When it is on, a red Safe Mode Active notice shows at the top of every Aegis screen with Turn Off Safe Mode (or Open Snippet Settings when the constant is defined). Click the × to hide the notice for the rest of your browser session; it comes back in a new session while Safe Mode is still on.
Safe Mode in the Admin Bar
Turn on Safe Mode in the admin bar in the Snippet settings card to also show a red Safe Mode item in the top admin bar, in the dashboard and on the front end, while Safe Mode is on. Its menu explains what is off and has Turn Off Safe Mode. It is off by default.
Admin screens still work in Safe Mode so you can pause or fix the offending snippet first. shows “Snippets are disabled” to administrators and nothing to everyone else.
Location Reference
The Snippets Settings tab includes an Available locations card (groups folded by default; click a group to open it). Switch each injection hook on or off for custom Content/PHP locations, or use Enable All / Disable All at the top of the card, then Save Settings. First-class type locations (header, shortcode, CSS frontend, and so on) do not depend on that catalog.
Snippet Settings
Global snippet settings (PHP opt-in, preview toggles, admin bar shortcuts) are in the Snippet settings card on Aegis → Code Snippets → Settings. Safe Mode is a separate card on that tab, with a visible URL, Copy, and Regenerate. Save Settings stays in view at the bottom of the screen and confirms with a green Settings saved. notice at the top of the screen.
The admin bar Positions item counts enabled hook patterns and snippets and uses singular/plural labels. See Injection Preview.
Next Steps
- Injection Preview — Visual hook preview
- Hook Patterns — Hook catalog
- General Settings — Settings export scope (snippets excluded)