Manage code snippets
code_snippetInsert PHP, CSS, or JavaScript as managed snippets that survive theme updates, with syntax checking for PHP and disabled-by-default activation for safe review.
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. |