# Code Snippets for WordPress

> Add PHP, CSS, JavaScript and HTML snippets without editing theme files — with conditions, revision history and automatic shut-off if a snippet breaks. Part…

TW-COR-03 Core


Add PHP, CSS, JavaScript and HTML snippets without editing theme files — with conditions, revision history and automatic shut-off if a snippet breaks.

[Get it from $26 a year](https://togglework.app/pricing/#plans) [Try it in the demo](https://togglework.app/demo/)

Code Snippets

**Part number**
: TW-COR-03
**Section**
: [Core](https://togglework.app/features/core/)
**Settings**
: Own screen
**Starts**
: Switched off
**In plans**
: Every plan

## Why it matters

Small customisations (a PHP function, a CSS tweak, a tracking script) are usually pasted into the theme’s functions.php. They vanish when the theme updates or changes, and one typo can take the whole site down.

A snippets manager keeps them separate from the theme, with conditions and history, and protects the site from a broken snippet.

### What it does

- PHP, CSS, JavaScript and HTML snippets, managed in wp-admin.
- Conditions for where and when each snippet runs.
- Revision history for every snippet.
- Switches a snippet off automatically if it causes a fatal error.

![Code Snippets settings screen in the Toggleworks WordPress plugin](https://togglework.app/wp-content/themes/toggleworks-site/assets/img/parts/core-code-snippets.webp?v=1795524155)

The Code Snippets screen in wp-admin, where you switch it on and change its settings.

## Set it up

1. Switch Code Snippets on and move your functions.php customisations into snippets one by one.
2. Give each a clear name and note what it does.

## How you use it

Switch Code Snippets on in Toggleworks → Core and it adds its own screen to wp-admin, where you do the work. There are no settings to get wrong first.

## Good to know

- Only administrators who can post unfiltered HTML can manage snippets.
- If a snippet ever does lock you out, `define( 'TOGGLEWORKS_SNIPPETS_SAFE', true );` in wp-config.php stops snippets only.

## One less plugin to install

Code Snippets does a job people often install a separate plugin for:

- Code snippets and header/footer codeOften done with ASE
- Adding PHP, CSS and JavaScript snippetsOften done with WPCode

## Comes with 187 more parts

Code Snippets is one part of Toggleworks, a single plugin for security, speed, SEO, backups, email and store tools. Switch on what your site needs; the rest stays off and loads nothing.

[All 27 Core parts](https://togglework.app/features/core/)

### People also look for it as

- snippets
- php
- functions.php
- custom code
- css
- javascript
- html

## Often switched on with it

- [Header & Footer Code](https://togglework.app/features/core/header-footer-code/) — TW-COR-12 · Add analytics tags, pixels, meta tags or custom CSS to every page without editing the theme. · 5 settings
- [System Info](https://togglework.app/features/core/system-info/) — TW-COR-25 · A copyable report of your WordPress, PHP, database, theme, plugin and cron setup, handy for support requests. · Own screen in wp-admin
- [Asset Manager](https://togglework.app/features/performance/asset-manager/) — TW-PRF-01 · See every CSS and JavaScript file a page loads and switch off the ones it does not need — on one page, everywhere, or everywhere… · Own screen in wp-admin
- [Defer & Delay JavaScript](https://togglework.app/features/performance/defer-scripts/) — TW-PRF-05 · Stop scripts from blocking page rendering by deferring them, or delaying them until the visitor interacts. Test your key pages… · 6 settings
- [Email Tweaks](https://togglework.app/features/email/email-tweaks/) — TW-EML-03 · Change the sender name and address, switch off noisy core notification emails, and give plain-text emails a branded HTML layout. · 9 settings
- [HTML to Bricks](https://togglework.app/features/bricks/html-to-bricks/) — TW-BRX-06 · Paste any HTML (a template, a design export, a landing page) and get editable Bricks elements to paste straight into the builder. · Own screen in wp-admin

## Questions

**Is Code Snippets included in every Toggleworks plan?**

Yes. Every plan includes all 188 parts, Code Snippets among them. Plans differ only in how many sites you can use them on, and staging or local copies of a site don’t count.

**Does Code Snippets slow my site down when it’s switched off?**

No. Every part starts switched off, and a part that is off loads none of its code. Switch on Code Snippets only if your site needs it.

**What if a setting locks me out?**

Add `define( 'TOGGLEWORKS_SAFE_MODE', true );` to wp-config.php. It pauses every part until you remove the line, and Tools → Recent changes lets you undo a change.

**Can I try Code Snippets before I buy?**

Yes. The [live demo](https://togglework.app/demo/) runs a WordPress site with Toggleworks in your browser, and every plan has a 14-day refund.

## Switch off the plugin pile.

All 188 parts, one license, updates and support. 14-day refund.

[Choose a plan](https://togglework.app/pricing/#plans) [Try the live demo](https://togglework.app/demo/)

---

Source: https://togglework.app/features/core/code-snippets/
