Manage code snippets
code_snippetAdd PHP, CSS, or JavaScript to WordPress as managed snippets that survive theme updates and remain disabled until activated, with PHP syntax checked before saving.
Instructions
Add PHP, CSS or JavaScript to the site as a managed snippet rather than by editing theme files — so it survives theme updates and can be switched off without touching code. New snippets are always created DISABLED: you activate them in wp-admin after reading the code. PHP snippets are syntax-checked before they are saved, so a parse error is reported rather than fataling the site.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Snippet id, for get/update/delete. | |
| code | No | The snippet body. For PHP, omit the opening <?php tag. | |
| title | No | Snippet name, for create/update. | |
| action | Yes | What to do. | |
| confirm | No | Required for delete. | |
| site_id | No | Which configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids. | |
| language | No | Snippet language, for create. | |
| location | No | Where it runs. CSS and JS snippets usually want header or footer. | everywhere |
| description | No | Why this snippet exists — worth writing, since someone will find it later. |