Skip to content

Free & open source

SnippetCrate

Add PHP, JavaScript, CSS and HTML to WordPress without editing a single theme file — and without the fear that one typo takes the whole site offline.

WordPress 5.2+  ·  PHP 7.4+  ·  GPLv2+

The editor

A real editor, not a textarea

Snippets are written in a CodeMirror editor with syntax highlighting and line numbers, so your code actually looks like code.

PHP, JavaScript, CSS and HTML

Live syntax highlighting and line numbers

Language, scope and priority in one panel

The SnippetCrate editor, showing a PHP snippet with syntax highlighting alongside its language, scope and priority controls.

// The safety net

Errors caught before they reach your site

Syntax is checked live as you type — PHP on the server, JavaScript in your browser — and code that does not parse cannot be saved.

Before saving

PHP is parsed with token_get_all() using the TOKEN_PARSE flag, which fully parses the code without running any of it. Code that does not parse is rejected.

At runtime

Every execution is wrapped in try / catch. If an active snippet throws, it is deactivated immediately, so the next page load no longer runs it.

Being straight about the limit: this contains anything PHP can throw, which is the overwhelming majority of mistakes. It cannot rescue you from a snippet that loops forever or exhausts the memory limit, because PHP cannot catch those.

// Scope

Decide exactly where each snippet runs

Every snippet has a scope, so nothing runs anywhere you did not intend.

Global

PHP only. Runs on every front-end request, the way a snippet in functions.php would.

Header / Footer

Printed in wp_head or wp_footer. Works with PHP, JavaScript, CSS or HTML.

Shortcode

Renders only where you place it, using the shortcode shown on the edit screen.

At scale

Built to manage more than three snippets

Duplicate any snippet. Filter by status, language, tag or date. Bulk activate, deactivate, export or delete. Import and export your whole library as JSON, or export your PHP snippets to a plain .php file.

Locked to administrators

Every admin screen and every REST endpoint is capability-checked against manage_options and nonce-protected. Nobody below administrator can add, edit or run code.

The SnippetCrate add-snippet screen.

// Questions

The things people ask first

What happens if my PHP snippet has an error?

It will not save if it does not parse. If an active snippet throws at runtime, the error is caught and the snippet is deactivated automatically, so your site stays up.

Which languages are supported?

PHP, JavaScript, CSS and HTML. Only PHP can use the Global scope; everything else runs in the header, the footer, or via shortcode.

Who can add or run snippets?

Administrators only — users with the manage_options capability.

How do I run a snippet in just one place?

Set its scope to Shortcode and insert the shortcode shown on the edit screen wherever you want it to render.

// Installing

Installing the zip

SnippetCrate is distributed from this site rather than the WordPress.org directory, so installation is the standard upload route.

  1. Download the zip using the button at the top of this page.
  2. In WordPress, go to Plugins → Add New → Upload Plugin.
  3. Choose the file and click Install Now, then Activate.
  4. SnippetCrate appears in the admin menu.

Because it is not in the WordPress.org directory, WordPress will not notify you when a new version is released, and it will not update itself. Check back here, or ask us to tell you.

Stop editing functions.php

Free, GPL licensed, and it will not break your site.