Skip to main content
All snippet endpoints are available since v1.4.0.

GET /snippets

Returns all saved code snippets ordered by ID descending.
curl -X GET https://example.com/wp-json/wp-manager-pro/v1/snippets \
  -H "X-WP-Nonce: YOUR_NONCE"

Response

snippets
array

POST /snippets

Creates a new code snippet. New snippets are saved in a disabled state and must be explicitly enabled.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/snippets \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"title": "Disable comments", "code": "add_filter(\"comments_open\", \"__return_false\");", "type": "php"}'

Parameters

title
string
required
A descriptive name for the snippet.
code
string
required
The snippet code. For PHP snippets, the opening <?php tag is optional and will be stripped before execution.
type
string
Snippet type: php, css, or js. Defaults to php.
description
string
Optional description of what the snippet does.

Response

Returns HTTP 201 on success.
success
boolean
Always true.
snippet
object
The newly created snippet object with all fields.

PUT /snippets/

Updates an existing snippet. All parameters are optional — only the provided fields are updated.
curl -X PUT https://example.com/wp-json/wp-manager-pro/v1/snippets/5 \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"title": "Disable comments site-wide", "code": "add_filter(\"comments_open\", \"__return_false\"); add_filter(\"pings_open\", \"__return_false\");"}'

Parameters

title
string
New title for the snippet.
code
string
Updated snippet code.
type
string
Updated type: php, css, or js.
description
string
Updated description.

Response

success
boolean
Always true.
snippet
object
The updated snippet object with all fields.

POST /snippets//toggle

Enables or disables a snippet. Enabled PHP snippets run on every page load via the after_setup_theme hook.
PHP snippets run with eval() in the context of the WordPress bootstrap. Test snippets in a staging environment before enabling them on production.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/snippets/5/toggle \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}'

Parameters

enabled
boolean
required
true to enable the snippet, false to disable it.

Response

success
boolean
Always true.
enabled
boolean
The new enabled state.

DELETE /snippets/

Permanently deletes a snippet.
Deleted snippets cannot be recovered. If the snippet is currently enabled, it stops running immediately.
curl -X DELETE https://example.com/wp-json/wp-manager-pro/v1/snippets/5 \
  -H "X-WP-Nonce: YOUR_NONCE"

Response

success
boolean
Always true on success.

Build docs developers (and LLMs) love