30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Delete Code Snippet

snippets/delete-snippet permanently deletes a snippet. It refuses without confirm: true.

It also does something a plain deletion does not: it verifies the snippet has actually left the loader cache.

Before you run it

This cannot be undone. The code is gone, and if it was the only copy it is not recoverable from anywhere in WordPress. snippets/deactivate-snippet stops the code running while keeping it, and is the right call almost every time somebody says “get rid of this snippet”.

At a glance

Abilitysnippets/delete-snippet
ToolsetWPCode — toolset/wpcode
GroupWPCode › Snippets
RequiresWPCode, active on the site
Capabilitymanage_options
SafetyDestructive — deletes stored values, and refuses to run without confirm: true
RepeatableNot idempotent — each call changes the row set, so re-running is not a no-op
Ships inAcrossAI Abilities Manager 0.0.34 and later

How it works

WPCode does not read the snippets table on every request. It builds a loader cache and runs from that, which is why a snippet can be published in the database and still be completely inert — and why writing the snippet post type directly through the content or database abilities produces a row that looks right and does nothing.

Which produces a genuinely alarming failure mode for deletion: remove the post with WordPress’s own function and the snippet is gone from the admin, gone from the database, and still in the cache — still executing on every request, with no row anywhere to explain where the code is coming from.

So this deletes the snippet, rebuilds the cache, and checks that the snippet is no longer in it before reporting success. A deletion that cannot be confirmed is reported as a failure rather than a success.

Deactivate first if you are diagnosing rather than removing. Deletion is for snippets you are certain about.

Input

NameTypeRequiredWhat it is
idintegerYesSnippet ID.
confirmbooleanYes — must be trueThe irreversibility gate. Without it the call is refused before anything is touched.

What comes back

NameTypeWhat it is
deleted_idintegerThe ID of the deleted snippet.
titlestringIts title, for the record.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

Delete the old redirect snippet for good.

It resolves to one call:

{
  "ability": "snippets/delete-snippet",
  "parameters": {
    "id": 88,
    "confirm": true
  }
}

Worth knowing

  • No trash, no undo. The code is gone.
  • Copy the code out first if there is any chance you want it back.
  • The cache is rebuilt and verified — a snippet that would keep running is reported, not ignored.
  • Prefer deactivation while diagnosing.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading