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

Start free trial

Update Global Header and Footer Scripts

snippets/update-global-scripts replaces the site-wide header, body or footer script. Send only the slots you want to change.

Each slot you send is replaced in full. There is no append.

At a glance

Abilitysnippets/update-global-scripts
ToolsetWPCode — toolset/wpcode
GroupWPCode › Global Scripts
RequiresWPCode, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI Abilities Manager 0.0.34 and later

Every page, and a full replacement

This markup runs on every page of the site, including checkout and login. There is no location, no conditional logic and no active flag to limit it — whatever goes in here is on every request. And each slot is replaced wholesale: sending a new header script discards the existing one entirely, which is how analytics tags get removed by accident.

Replacement, not merge

The value you send becomes the slot’s entire contents. That is the right primitive — it is unambiguous and it makes the operation idempotent — but it means “add our new analytics tag to the header” is a read-then-write, not a single call.

Read the current value with snippets/get-global-scripts, append to it, send the result. Skipping the read is how a site loses a tag that had been there for years.

Slots you do not send are untouched, so changing the footer cannot disturb the header.

The body slot depends on the theme calling wp_body_open. Writing to it on a theme that does not is accepted and does nothing; the read ability reports whether the theme supports it.

For anything that needs a location, a condition or an off switch, a snippet is the better home. These three fields are for markup that genuinely belongs on every page.

Input

NameTypeRequiredWhat it is
headerstringNoMarkup for the site head. Replaces the current value entirely.
bodystringNoMarkup for just after the opening body tag. Only rendered by themes that call wp_body_open.
footerstringNoMarkup for the site footer. Replaces the current value entirely.
confirmbooleanYes — must be trueThe irreversibility gate. Without it the call is refused before anything is touched.

What comes back

NameTypeWhat it is
headerstringThe header slot after the write.
bodystringThe body slot after the write.
footerstringThe footer slot after the write.
updatedarrayWhich slots were changed.
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:

Add our new analytics tag to the site header.

It resolves to one call:

{
  "ability": "snippets/update-global-scripts",
  "parameters": {
    "header": "<!-- existing tags -->\n<script src=\"https://example.com/a.js\"></script>",
    "confirm": true
  }
}

Worth knowing

  • Read before you write. The slot is replaced, not appended to.
  • Slots you omit are left alone.
  • This markup has no conditions and no off switch. A snippet does.
  • Idempotent — the same payload twice leaves the same result.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading