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.

TypeRuns asDefault locations
Functions (PHP)Included like functions.php (requires PHP opt-in)Everywhere, frontend, admin, login, or a custom injection hook
ContentHTML, or mixed PHP + HTML when PHP is enabledSite header, body open, footer, before/after content, shortcode, or a custom hook
CSSEnqueued stylesheetFrontend, admin, login, or block editor
JavaScriptEnqueued scriptFrontend/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.

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:

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.

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.

SettingDescription
PHP snippetsMaster switch for PHP snippet execution
Auto Safe Mode on fatal errorEnable Safe Mode automatically when a PHP snippet fatals
Enable Safe ModeDisable all snippets and hook pattern output site-wide
Safe Mode URLSecret ?aegis_safe_mode=TOKEN link that turns Safe Mode on without logging in. Copy and Regenerate sit next to the URL.
AEGIS_DISABLE_SNIPPETSdefine( '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