Documentation
SnippetCrate
Adding your first snippet, choosing a scope, the shortcode, importing and exporting, and what happens when a snippet errors.
// Getting started
Install it
- Install from Plugins → Add New, or upload the
snippetcratefolder to/wp-content/plugins/. - Activate it on the Plugins screen.
- Open SnippetCrate from the admin menu.
SnippetCrate needs WordPress 5.2 or newer and PHP 7.4 or newer. Only administrators — users with manage_options — can see any of it.
Your first snippet
- Click Add New Snippet.
- Give it a name you will recognise in six months.
- Choose the language: PHP, JavaScript, CSS or HTML.
- Choose the scope — where it runs. See below.
- Paste the code. The editor checks the syntax as you type.
- Save & Activate.
PHP is validated on your server and JavaScript in your browser, so a snippet that does not parse cannot be saved at all. That check is on syntax, not on whether the code does what you meant.
// Scope
Scopes: where a snippet runs
Every snippet has a scope, so nothing runs anywhere you did not intend. The scope you can pick depends on the language.
Global snippets are hooked to wp, which never fires in wp-admin, in REST requests or in cron. A broken global snippet therefore cannot lock you out of your own dashboard.
Running one in a single place
Set the scope to Shortcode and drop [snippetcrate_snippet id="X"] wherever you want it, where X is the id shown on the edit screen.
// Safety
When a snippet goes wrong
Two separate safety nets, and it is worth knowing which one catches what.
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. Test substantial snippets on a staging site first.
// Library
Managing more than a handful
Duplicate any snippet as a starting point for the next one.
Filter the list by status, language, tag or date.
Bulk activate, deactivate, export or delete.
Import and export the whole library as JSON, or export just your PHP snippets to a .php file.
// FAQ
Questions
Who can add or run snippets?
Only administrators, meaning users with the manage_options capability. Every admin screen and every REST endpoint is capability-checked and nonce-protected. On a multisite network a Super Admin is required as well.
Which languages can use which scope?
PHP, JavaScript, CSS and HTML are all supported. Only PHP can use the Global scope; every other language runs in the header, the footer, or through the shortcode.
Is JavaScript, CSS or HTML ever evaluated?
No. Only PHP is executed. The others are printed as markup into the header or footer.
Does the plugin load anything from a third-party server?
No. The admin app, the code editor and the fonts are all bundled with the plugin and served from your own site.
Does uninstalling remove my snippets?
Deleting the plugin removes its database table and its options. Deactivating the plugin leaves your snippets intact.
Still stuck?
If something here is wrong or missing, tell us and we will fix it — then write it down for the next person.
