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

Start free trial

Duplicate Code Snippet

snippets/duplicate-snippet copies a snippet. The copy is inactive, with Copy appended to its title.

It uses WPCode’s own duplicate routine, which matters more than it sounds.

At a glance

Abilitysnippets/duplicate-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 the copy routine, and not a read-then-write

Copying a snippet by reading its code and writing it back is where backslashes go to die. WordPress slashes and unslashes data on the way through its own save path, and code — regular expressions especially — is full of backslashes that a round trip quietly halves.

WPCode’s duplicate routine copies the stored value directly, so the copy is byte-for-byte the original. A regex that worked in the source works in the copy.

Inactive by default, which makes duplication the safe way to experiment: copy the working snippet, edit the copy, activate it, and the original is untouched the whole time.

Not idempotent — each call produces another copy.

Input

NameTypeRequiredWhat it is
idintegerYesSnippet ID.

What comes back

NameTypeWhat it is
snippetobjectThe new copy.
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:

Make me a copy of snippet 88 so I can edit it safely.

It resolves to one call:

{
  "ability": "snippets/duplicate-snippet",
  "parameters": {
    "id": 88
  }
}

Worth knowing

  • The copy is inactive. Nothing starts running.
  • Code is preserved exactly, including backslashes.
  • Not idempotent. Two calls, two copies.
  • The safe way to try a change to a snippet that is currently working.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading