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

Start free trial

Update Snippet From Library

snippets/update-snippet-from-library replaces an installed snippet with the newer version from the library. It refuses without confirm: true.

It keeps whatever active state the snippet had here — which is a deliberate departure from what the plugin’s own updater does.

At a glance

Abilitysnippets/update-snippet-from-library
ToolsetWPCode — toolset/wpcode
GroupWPCode › The Library
RequiresWPCode, active on the site
Capabilitymanage_options
SafetyWrites data
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

Local edits are lost

This overwrites the snippet’s code completely. Any local edit — a changed threshold, a removed line, a fix somebody made here — is lost, and there is no copy kept. Read the snippet with snippets/get-snippet first if there is any chance it was modified after installation.

Why the active state is preserved

WPCode’s own updater takes the active state from the library payload. So a snippet you deliberately switched off — because it conflicted with something, or because you were mid-investigation — comes back on as a side effect of an update, and nothing reports it.

That is a surprising thing for an update to do. This ability reads the local state before the write and restores it afterwards, so updating changes the code and only the code.

The code itself is replaced wholesale. There is no merge, and local modifications are not detected or preserved — which is the reason for the confirmation, and the reason to read the snippet first if anybody might have edited it here.

If the updated code is PHP and the snippet was active, WPCode’s activation check runs again on save. A new version that errors leaves the snippet off, and the response reports that rather than claiming a clean update.

Input

NameTypeRequiredWhat it is
idintegerYesLocal snippet ID, from snippets/list-snippet-updates.
confirmbooleanYes — must be trueThe irreversibility gate. Without it the call is refused before anything is touched.

What comes back

NameTypeWhat it is
snippetobjectThe snippet after the update.
in_cachebooleanWhether WPCode’s loader cache holds the snippet. This, not the post status, is what decides whether it actually runs.
safe_modebooleanWhether safe mode is active. When it is, no snippet runs regardless of everything else.
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:

Pull the latest version of snippet 88 from the library.

It resolves to one call:

{
  "ability": "snippets/update-snippet-from-library",
  "parameters": {
    "id": 88,
    "confirm": true
  }
}

Worth knowing

  • Local edits are overwritten with no copy kept.
  • The local active state is preserved — a deliberately disabled snippet stays disabled.
  • An updated PHP snippet can fail the activation check and end up off. The response says so.
  • Requires the site to be signed in to the library.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading