Skip to main content
Glama

Delete a snippet

wp_delete_php_snippet
Destructive

Move a PHP snippet of Code Snippets or WPCode to the plugin's trash, or delete it for good with force: true. The id is the one wp_list_php_snippets lists. An active snippet stops running, so the test requests follow, and a fatal error (other code needing its functions) brings it back. Test requests then check that the site still runs, as wp_write_plugin_file does: the home page, this MCP endpoint (its own 401 is the expected answer), wp-admin/admin-post.php (runs admin_init, so admin snippets run there) and the dashboard in wp-admin, logged in as the account of this connection. A fatal error at any of them, or reaching none of them, puts the previous state back at once and the answer names target, error, file and line; this MCP endpoint ending early, or one target not reached while others are, is asked again with the previous state, and the change stays out where that answers. Not checked: wp-admin screens other than the dashboard (the editors, settings pages), cron, AJAX, and code that runs only on some pages or for other users; errors there are left to the snippet plugin: Code Snippets catches errors while a snippet loads, CODE_SNIPPETS_SAFE_MODE in wp-config.php stops every snippet and ?snippets-safe-mode=1 browses without them; WPCode switches off a snippet that ends a wp-admin request with an error, WPCODE_SAFE_MODE in wp-config.php stops every snippet and ?wpcode-safe-mode=1 in wp-admin or on the login page browses without them. While a safe mode stops every snippet, the test requests are skipped and the answer says so. Every change first records an undo point (wp_undo writes the plugin's record back byte for byte, with the same test requests, and keeps the current record where the site does worse with the old one) and is refused if that fails; a snippet too large for one needs allow_without_undo, and with undo switched off on the site the change goes ahead with a warning. The audit log notes the snippet name and the sha256 of the code before and after. Not on multisite; blocked by DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS. Forwarded by AlphaBridge Connect to the one site this connection reaches.

Input Schema

NameRequiredDescriptionDefault
idYesSnippet id, as wp_list_php_snippets lists it.
forceNotrue deletes for good instead of moving the snippet to the trash. Default false.
providerNoSnippet plugin: code-snippets (Code Snippets) or wpcode (WPCode). Needed only when both are active.
allow_without_undoNotrue makes the change although the snippet is too large for an undo point (over the undo size limit): the change then has no way back. Only for that case.
allow_without_probeNotrue keeps the change although the test requests afterwards fail, where the previous state fails the same way: a fatal error that was there before, or a site that cannot reach itself (an HTTP login or a firewall in front of it). Every target is then asked, and each failure is asked again with the previous state; a failure the previous state does not have still puts it back.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / allow_without_probe / description
      Previous value: -"Keep the change although the test requests afterwards fail, where the previous state fails the same way: a fatal error that was there before, or a site that cannot reach itself (an HTTP login or a firewall in front of it). Every target is then asked, and each failure is asked again with the previous state; a failure the previous state does not have still puts it back."New value: +"true keeps the change although the test requests afterwards fail, where the previous state fails the same way: a fatal error that was there before, or a site that cannot reach itself (an HTTP login or a firewall in front of it). Every target is then asked, and each failure is asked again with the previous state; a failure the previous state does not have still puts it back."
    • changedInput schema / properties / allow_without_undo / description
      Previous value: -"Go ahead although the snippet is too large for an undo point (over the undo size limit): the change then has no way back. Only for that case."New value: +"true makes the change although the snippet is too large for an undo point (over the undo size limit): the change then has no way back. Only for that case."
    • changedInput schema / properties / force / description
      Previous value: -"Delete for good instead of moving it to the trash. Default false."New value: +"true deletes for good instead of moving the snippet to the trash. Default false."
    • changedInput schema / properties / id / description
      Previous value: -"Snippet id."New value: +"Snippet id, as wp_list_php_snippets lists it."
  2. Added

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the destructiveHint annotation, the description discloses extensive behavior: active snippets stop running, test requests probe the home page, MCP endpoint, admin-post.php, and dashboard, fatal errors restore the previous state, safe modes skip probes, undo points are recorded, and audit logging includes sha256 hashes. It also states multisite and DISALLOW_FILE_EDIT / DISALLOW_FILE_MODS restrictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose and force behavior are front-loaded, but the description is extremely dense and runs long for a single delete operation, packing many clauses into long sentences. Most content is substantive, but the structure makes it harder to scan than necessary.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the destructive nature, probe behavior, undo recording, safe-mode interactions, and absence of an output schema, the description is remarkably complete. It covers rollback behavior, what the answer names on failure, safe-mode skipping, and site restrictions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3, but the description adds meaningful semantics beyond the schema: it explains that force true deletes for good, that allow_without_undo applies to snippets too large for an undo point, and that allow_without_probe applies where the previous state fails the same way. Provider detail is left to the schema enum.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Move a PHP snippet of Code Snippets or WPCode to the plugin's trash, or delete it for good with force: true.' It also distinguishes the tool from sibling listing tools by saying the id is the one wp_list_php_snippets lists.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear conditions for force deletion and the allow_without_undo / allow_without_probe escapes, and it explains which snippet id source to use. It does not explicitly compare this tool to a sibling alternative or state when not to use it, but the intended context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources