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

Start free trial

Update Code Snippet

snippets/update-snippet changes a snippet: its code, title, note, priority, tags or custom shortcode. Only the fields you send are touched.

If the snippet is active, the save re-runs WPCode’s activation check — and the result of that check is reported rather than assumed.

At a glance

Abilitysnippets/update-snippet
ToolsetWPCode — toolset/wpcode
GroupWPCode › Snippets
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

Why editing executable code needs confirmation

PHP and universal snippets execute on this site. Code arriving through an assistant is code somebody described rather than wrote, and the gap between the description and what the code does is exactly where this goes wrong. The confirmation is there to make that a deliberate step rather than a consequence of a sentence. Editing an active PHP snippet is the sharper case: the new code runs on the next request, and if it fatals WPCode switches the snippet off.

The check that runs on save

WPCode test-runs PHP and universal code when a snippet is saved in an active state. If the code errors, it leaves the snippet switched off and still reports the save as successful. From the outside that is indistinguishable from a working edit until somebody notices the feature is gone.

So this reads the state back after saving. A snippet that went in and came out inactive is reported as such, with the error WPCode recorded, instead of a clean success.

That makes editing an active PHP snippet a two-outcome operation, and both outcomes are visible: either the code took and the snippet is still running, or it did not and the snippet is off with a reason attached.

Partial updates are the default. Sending only priority leaves the code alone.

Input

NameTypeRequiredWhat it is
idintegerYesSnippet ID.
code_typestringNoChange the code type. Omit to keep the current one.
titlestringNoSnippet title.
codestringNoThe snippet body.
notestringNoInternal note. Never output anywhere on the site.
priorityintegerNo — defaults to 10Execution order; lower runs earlier.
custom_shortcodestringNoA custom shortcode tag for rendering this snippet manually.
tagsarrayNoTags, as a list of strings.
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 write, including its active state and any error recorded by the save-time check.
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:

Change the priority on snippet 88 so it runs earlier.

It resolves to one call:

{
  "ability": "snippets/update-snippet",
  "parameters": {
    "id": 88,
    "priority": 5
  }
}

Worth knowing

  • Editing an active PHP snippet can switch it off. The response says so when it happens.
  • Read the active state in the response — do not assume the edit left it running.
  • Clear the recorded error with snippets/clear-snippet-errors after fixing the code, so a later failure is unambiguous.
  • Confirmation applies to php and universal.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading