leaStudios Snippets WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA
Manage custom PHP, JavaScript, CSS, and HTML snippets without editing theme files. Auto-insert locations, conditional logic, safe-mode error handling, and a pre-built library of hooks for the leaStudios suite.
Install
Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/adamjohnlea/leastudios-snippets/releases/download/v1.1.4/leastudios-snippets-1.1.4.zipManage custom PHP, JavaScript, CSS, and HTML snippets without editing theme files. Auto-insert locations, conditional logic, safe-mode error handling, and a pre-built library of hooks for the leaStudios suite.
- Requires WordPress: 6.4+
- Requires PHP: 8.1+
- License: GPL-2.0-or-later
Features
- PHP, JS, CSS, HTML snippets managed from the admin.
- Auto-insert locations — header, footer, before/after content, and more.
- Conditional logic — page type, user role, post type, specific page IDs.
- Safe mode — snippets that throw fatal errors are auto-deactivated with an admin notice.
- Warning tracking — snippets that emit non-fatal PHP warnings stay active but surface a dismissible admin notice.
- Pre-built library of hooks for leaStudios suite plugins.
- Priority control for execution order.
Safety model
Only administrators with manage_options can create or edit snippets. A custom error handler captures fatal errors during snippet execution; the offending snippet is auto-deactivated and a safe-mode flag prevents re-execution until you fix and re-enable it. Fatal errors are contained even when they occur in deferred hooks or as uncatchable fatals, via a shutdown handler. If the site defines DISALLOW_FILE_MODS or DISALLOW_FILE_EDIT, creating and editing snippets is disabled (existing snippets keep running).
Installation
- Upload
leastudios-snippetsto/wp-content/plugins/. - Activate via Plugins → Installed Plugins.
- Go to Snippets in the admin menu and create your first snippet.
Related plugins
This plugin is part of the leaStudios plugin family. It works on its own, and ships pre-built snippets that hook into the other leaStudios plugins (payments, email-templates, forms, mailer) under the Library tab. Browse there if you want quick examples of customising the rest of the suite.
Development
This plugin is self-contained — it can be cloned, linted, tested, and packaged on its own.
composer install # install dependencies (incl. dev tools)
composer lint # phpcs + phpstan
composer test # phpunit (requires the WP test library)
composer phpcbf # auto-fix WPCS issues
To run the test suite, install the WordPress test library once:
bash ../leastudios-dev-tools/bin/install-wp-tests.sh wordpress_test root '' localhost latest
The shared scaffold, packaging script, and project-wide development conventions live in leastudios-dev-tools — start there when bootstrapping a new plugin or making cross-plugin tooling changes.
License
GPL-2.0-or-later. See readme.txt for the WordPress.org-style header.
Releases
6 releases. Each count is every asset in that release; expand a row for the breakdown.