WP-CLI
Snipfire adds wp snipfire commands to WP-CLI. Run wp help snipfire <command> for the built-in help.
Commands marked Pro need Snipfire Pro; git, hub and network need the Agency plan (or its trial).
Unlike the editor, WP-CLI isn't limited by team access: anyone who can run WP-CLI on the server can do everything.
Snippets
list
wp snipfire list [--type=<php|css|js|html>] [--status=<active|inactive>] [--folder=<folder>]
[--hook=<hook>] [--fields=<fields>] [--format=<format>]
| Option | Meaning |
|---|---|
--type, --status |
Only this type, or only active or inactive snippets |
--folder |
Only snippets in this folder (not its subfolders) |
--hook |
Only snippets at this location, for example wp_head |
--fields |
Columns to show, comma-separated: id, title, folder, type, status, run, hook, priority, position, conditions, error |
--format |
table (default), json, csv, yaml, ids, count |
wp snipfire list --type=php --status=active
wp snipfire list --folder=Library --fields=id,title,status
wp snipfire list --format=count
get
wp snipfire get <id> [--field=<field>]
wp snipfire get 12 --field=code > snippet.php
create
wp snipfire create --title=<title> [--type=<type>] [--code=<code>] [--file=<file>]
[--hook=<hook>] [--position=<n>] [--priority=<n>] [--run=<auto|shortcode|manual|schedule>]
[--schedule=<json>] [--selector=<css>] [--selector-insert=<where>] [--selector-match=<n|all>]
[--shortcode=<tag>] [--lang=<css|scss|less>] [--mode=<live|test>] [--consent=<category>]
[--folder=<folder>] [--description=<text>] [--tags=<tags>]
[--load-as=<inline|file>] [--[no-]smart-tags] [--fields=<json>] [--values=<json>]
[--conditions=<json>] [--active] [--porcelain]
| Option | Meaning |
|---|---|
--type |
php (default), css, js or html |
--code / --file |
The code, or a file to read it from (- for stdin) |
--hook |
Where it runs: a location key from Location keys, or any action name for PHP/HTML |
--position |
Which paragraph, or which post in the list, for the HTML locations that take a number. Default 1 |
--priority |
Default 10 |
--run |
auto (default), shortcode, manual, or schedule (PHP; runs with Pro) |
--schedule |
For --run=schedule: {"every":"hourly\|twicedaily\|daily\|weekly\|minutes","minutes":15,"start":"2026-10-01 03:00"}. minutes (5 or more) only for minutes; start is optional, in the site's time zone. See Scheduled snippets |
--selector |
For --hook=element:selector (HTML; placed by Pro): the element's CSS selector, for example "#main .entry-content h2". See Next to an element |
--selector-insert |
For element:selector: before, after (default), start, end or replace |
--selector-match |
For element:selector: which matching element, 1 (the first, default), 2…, or all |
--shortcode |
Custom shortcode tag |
--lang |
CSS snippets: css, scss or less (Pro to compile) |
--mode |
live, or test for testing mode (Pro) |
--consent |
JS/HTML: statistics, marketing, preferences, functional, or "" for none (Pro) |
--folder |
For example "WooCommerce/Checkout" |
--description, --tags |
Notes; comma-separated tags |
--load-as |
CSS/JS: inline or file |
--smart-tags, --no-smart-tags |
HTML/JS: replace smart tags such as {post_title}, or not |
--fields |
Settings form fields as JSON, for example '[{"key":"color","label":"Colour","type":"color","default":"#f60"}]' |
--values |
The settings form's values as JSON, for example '{"color":"#09c"}'. On a new snippet, fields you leave out get their default |
--conditions |
Conditions as JSON; see Conditions as JSON. "" for none |
--active |
Switch it on after saving (after the checks and the test load) |
--porcelain |
Print only the new ID |
--fields, --values, --conditions and --schedule must be valid JSON of the right shape (a list for fields and conditions, an object for values and the schedule); otherwise the command stops with an error and changes nothing. "" means "none".
wp snipfire create --title="Disable XML-RPC" --code="add_filter( 'xmlrpc_enabled', '__return_false' );" --active
cat tracking.html | wp snipfire create --title="GA4" --type=html --hook=wp_head --file=- --porcelain
wp snipfire create --title="Newsletter box" --type=html --hook=the_content:paragraph_after --position=3 --file=box.html
update
wp snipfire update <id> [same options as create] [--replace-values] [--active] [--inactive]
Only the options you give change. --values changes only the keys you give and keeps the others; add --replace-values to replace them all (fields you leave out go back to their defaults).
wp snipfire update 12 --file=snippet.php
wp snipfire update 12 --mode=live
wp snipfire update 12 --values='{"measurement_id":"G-ABC123"}'
wp snipfire update 12 --values='{"message":"Sale"}' --replace-values
wp snipfire update 12 --run=schedule --schedule='{"every":"daily","start":"2026-10-01 03:00"}'
enable / disable / delete
wp snipfire enable <id>... [--skip-test]
wp snipfire disable <id>...
wp snipfire delete <id>...
enable checks each snippet and test-loads the site first, like the editor. --skip-test skips the test load (the checks still run).
run
wp snipfire run <id>
Runs a PHP or HTML snippet once and prints its output. Conditions are ignored.
generate
wp snipfire generate [<generator>] [--values=<json>] [--title=<title>] [--active] [--porcelain] [--format=<format>]
Makes a snippet with a generator. Without a generator ID, lists them with their fields, and in a needs column what a generator needs that this site doesn't have (for example Needs Snipfire Pro.). Such a locked generator stops with an error.
| Option | Meaning |
|---|---|
--values |
The form's values as JSON (an error if it isn't valid JSON). Fields you leave out get their defaults |
--title |
Snippet title (default: the generator's name) |
--active |
Switch it on after saving (after the checks and a test load) |
--porcelain |
Print only the new ID |
--format |
For the list: table (default), json, csv, yaml |
wp snipfire generate
wp snipfire generate post-type --values='{"key":"book","singular":"Book","plural":"Books"}' --active
wp snipfire generate redirects --values='{"rules":[{"from":"/old/","to":"/new/"}]}' --active
The snippet keeps its settings form: change the values later with wp snipfire update <id> --values=<json>.
smart-tags
wp snipfire smart-tags [--format=<table|json|csv|yaml>]
Lists the smart tags HTML and JavaScript snippets can use on this site, with their group, kind (text, url, number, json) and description. With Snipfire Pro and WooCommerce active, the WooCommerce order tags and {woocommerce_data} are included.
History
wp snipfire revisions <id> [--format=<table|json|csv|yaml>]
wp snipfire restore <id> <rev>
restore checks and test-loads the restored version like any save, and keeps the current version in the history.
Export and import
wp snipfire export [<id>...] [--file=<file>]
wp snipfire import <file> [--keep-status]
Imported snippets arrive switched off unless you add --keep-status.
export-plugin
wp snipfire export-plugin [<id>...] [--folder=<folder>] [--name=<name>] [--slug=<slug>] [--version=<version>]
[--include=<ids>|all] [--output=<file>] [--dry-run] [--format=<table|json>]
Exports snippets as a standalone plugin (a zip) that runs them without Snipfire. First prints the report: each snippet, whether it's exported, and why not.
| Option | Meaning |
|---|---|
<id>..., --folder |
The snippets: IDs, and/or every snippet in a folder and its subfolders |
--name |
The plugin's name. Default: the folder's name, or "My snippets" |
--slug |
Its folder and file name: lowercase letters, digits and dashes, not starting with snipfire. Default: from the name |
--version |
Default 1.0.0 |
--include |
IDs of snippets with issues to export anyway (comma-separated), or all. They're exported without the settings the plugin can't reproduce |
--output |
Where to write the zip. Default: <slug>.zip in the current folder |
--dry-run |
Only print the report |
--format |
The report as table (default) or json |
wp snipfire export-plugin 12 14 --name="Shop tweaks" --slug=shop-tweaks
wp snipfire export-plugin --folder=WooCommerce --include=all --output=/tmp/woo.zip
import-from
wp snipfire import-from [<source>] [--ids=<ids>] [--dry-run] [--update] [--switch] [--format=<table|json>]
Without a source, lists the plugins Snipfire found snippets for. Sources: wpcode, code-snippets, fluent-snippets, hfcm, custom-css-js, post-snippets, woody, customizer-css, wpcodebox.
| Option | Meaning |
|---|---|
--ids |
Only these snippets (the other plugin's IDs, comma-separated) |
--dry-run |
Show what would be imported and how, without importing |
--update |
Re-import snippets imported before (refreshes code and settings) |
--switch |
After importing, switch the snippets off in the other plugin and on in Snipfire |
See Switching from another plugin.
library
wp snipfire library [list|packs|show|install|update] [<slug>...] [--pack=<pack>] [--activate] [--all] [--format=<format>]
The snippet library.
| Action | What it does |
|---|---|
list (default) |
Every library snippet with its state on this site (new, current, changed, update), its snippet ID and status, and what it needs. --pack lists one pack |
packs |
The packs and how many snippets each has |
show <slug> |
One snippet: title, description, notes and code |
install <slug>... |
Install snippets, switched off, in the Library folder. --pack installs a whole pack. --activate switches them on after the checks and one test load; snippets that need your details or a missing plugin stay off |
update <slug>... |
Update installed snippets to the library's version, keeping the settings you changed. --all updates every snippet with an update |
--format for list and packs: table (default), json, csv, yaml, count.
wp snipfire library --pack=harden
wp snipfire library install --pack=clean-head --activate
wp snipfire library install disable-xmlrpc year-shortcode
wp snipfire library update --all
shortcodes
wp snipfire shortcodes [--rewrite] [--dry-run] [--state=<state>] [--limit=<n>] [--format=<format>]
Checks every post (unlike the Tools screen, which stops at 1,000) and lists where snippet shortcodes are used in posts, templates and widgets: Snipfire's own (and whether they print anything) and ones left over from WPCode, Code Snippets, FluentSnippets, Header Footer Code Manager, Woody Code Snippets and Post Snippets.
| Option | Meaning |
|---|---|
--state |
Only this state: ok, rewrite, kept, other, missing or inactive |
--rewrite |
Rewrite old shortcodes of switched-over snippets to [snipfire id="…"]. Posts get a revision first |
--dry-run |
With --rewrite: only say what would change |
--limit |
Only look at the first n posts (lowest IDs). Default: all of them |
--format |
table (default), json, csv, yaml, count |
See Find where shortcodes are used.
files
wp snipfire files [<file>] [--set=<text>]
The site files Snipfire serves. Without a file name, lists them with their address and whether a real file on the server takes precedence. File names: robots, ads, app-ads, llms, security.
wp snipfire files llms # show llms.txt
wp snipfire files llms --set=- < llms.txt # new contents from standard input
wp snipfire files ads --set="" # empty it: ads.txt is switched off
Safe mode, storage and system info
wp snipfire safe-mode [status|new-key]
wp snipfire info [--system] [--format=<text|json>]
info shows where Snipfire stores snippets and whether it can write there. info --system prints the full system info for a support ticket (as text, or --format=json): no secrets, code or email addresses.
To run any command with all snippets stopped, define the safe mode constant for that one command:
wp --exec='define( "SNIPFIRE_SAFE_MODE", true );' snipfire list
access Pro
wp snipfire access [list|set|check] [<role-or-user>] [<level>]
wp snipfire access # each role's level
wp snipfire access set editor design # none, view, design or full
wp snipfire access check jane # a user's level (login, email or ID)
design is the CSS, JS and HTML level. See Team access.
consent Pro
wp snipfire consent [status|fallback|gpc] [<value>]
wp snipfire consent # the consent tool found, the settings, and how many snippets wait
wp snipfire consent fallback allow # without a consent tool: block (the default) or allow
wp snipfire consent gpc off # Global Privacy Control: on (the default) or off
See Cookie consent.
preview Pro
wp snipfire preview [status|new-key]
Shows the testing mode preview link, or makes a new one (old links stop working).
log Pro
wp snipfire log [--snippet=<id>] [--user=<user>] [--action=<action>] [--limit=<n>] [--format=<table|json|csv|yaml>]
Actions: created, updated, enabled, disabled, auto_disabled, deleted, restored, imported, switched_over, moved, settings, access, git_pulled, git_sync, update_refused, export_plugin, hub_pushed, site_off, site_on. Default limit 50. See Activity log.
schedule Pro
wp snipfire schedule list [--format=<format>]
wp snipfire schedule run <id>
wp snipfire schedule log <id> [--limit=<n>] [--output] [--format=<format>]
Scheduled snippets. list shows every snippet that runs on a schedule, with its next and last run. run runs one now (even if it's switched off) and records it in its run log; an error switches a snippet that's on off, as on the site. log shows the run log, newest first; --output adds each run's output. Put a snippet on a schedule with --run=schedule --schedule=<json> on create or update.
profile Pro
wp snipfire profile [--sort=<field>] [--reset] [--mode=<off|admins|sample>] [--rate=<n>] [--slow=<ms>] [--format=<format>]
Snippet performance: each snippet's time and memory per page, from the last week of measurements.
| Option | Meaning |
|---|---|
--sort |
avg (default), p95, max, count, last, kb or id |
--reset |
Delete all measurements |
--mode |
What to measure: off, admins (admins' own page views) or sample |
--rate |
With --mode=sample: measure 1 in n requests |
--slow |
Flag snippets from this average time, in ms |
--format |
table (default), json, csv, yaml |
secret Pro
wp snipfire secret list [--format=<format>]
wp snipfire secret set <name> [--value=<value>]
wp snipfire secret delete <name> [--yes]
wp snipfire secret rekey
The secrets vault. list shows names, masked hints, dates, the key state and where each is used, never the values; there's no command that prints one. set adds a secret or replaces its value, read from standard input (piped, or typed hidden at the prompt); --value works too but stays in your shell history. rekey re-encrypts every secret with the current key, for example after adding SNIPFIRE_SECRETS_KEY.
printf %s "$STRIPE_KEY" | wp snipfire secret set stripe_key
ai Pro
wp snipfire ai status [--format=<table|json>]
wp snipfire ai setup [--provider=<anthropic|openai|compatible>] [--model=<model>] [--base-url=<url>]
[--timeout=<seconds>] [--max-tokens=<n>] [--access=<full|design>] [--enable] [--disable]
wp snipfire ai test
The AI assistant. status shows the settings (never the key); setup changes only the options you give (--model="" for the provider's default; --base-url for an OpenAI-compatible provider; --timeout 5 to 300 seconds; --access=design lets people with CSS, JS and HTML access use it too); test sends a tiny request. The API key is the secret ai_api_key: wp snipfire secret set ai_api_key.
git Agency
Needs the Agency plan or its trial.
wp snipfire git setup [--provider=<github|gitlab>] [--repo=<repo>] [--branch=<branch>]
[--root=<folder>] [--scope=<folder>] [--token=<token>] [--remove-token] [--api=<url>]
[--schedule=<off|hourly|twicedaily|daily>] [--check]
wp snipfire git check
wp snipfire git sync [--format=<text|json>]
wp snipfire git status [--format=<text|json>]
wp snipfire git resolve <uid>... --keep=<site|git> [--format=<text|json>]
wp snipfire git reset
setup option |
Meaning |
|---|---|
--provider |
github or gitlab |
--repo |
owner/name, or the repository's address |
--branch |
Default main |
--root |
Folder in the repository. Default snipfire; "" for the top |
--scope |
Only sync this Snipfire folder (and subfolders); "" for all |
--token / --remove-token |
Save (encrypted) or remove the access token. Or define SNIPFIRE_GIT_TOKEN |
--api |
API address for GitHub Enterprise Server or self-managed GitLab |
--schedule |
Automatic sync |
--check |
Test the connection afterwards |
setup only changes the options you give. resolve all --keep=site settles every conflict. See Git sync.
hub Agency
Needs the Agency plan or its trial. See Agency hub.
wp snipfire hub sites [--format=<format>]
wp snipfire hub add <url> --username=<user> [--password=<password>] [--name=<name>] [--porcelain]
wp snipfire hub remove <id> [--yes]
wp snipfire hub status [<id>] [--refresh] [--format=<format>]
wp snipfire hub pull-status [--format=<format>]
wp snipfire hub push [<ids>] [--folder=<folder>] --sites=<ids|all> [--on] [--overwrite|--keep] [--format=<format>]
wp snipfire hub where <id> [--refresh] [--format=<format>]
wp snipfire hub rollback <id> --site=<id> [--action=<previous|disable|remove>] [--rev=<rev>]
| Command | What it does |
|---|---|
sites |
The connected sites and what the hub last saw there |
add |
Connect a site with an application password (made on that site under Users → Profile; the user needs full Snipfire access). Without --password, it's read from standard input. The option is --username because --user is WP-CLI's own |
remove |
Forget a site. Revoke its application password on the site yourself |
status |
Health: versions, snippets with errors, safe mode, last contact. --refresh asks the sites now |
pull-status |
Ask every site now, like Refresh all |
push |
Push snippets (IDs on this site, comma-separated, and/or a --folder) to sites. --on switches them on there (checked and test-loaded on each site). A copy changed on a site is left alone unless you add --overwrite (the hub's version) or --keep (the site's) |
where |
Every site, whether it has the snippet, which version, on or off |
rollback |
On one site: previous (default: push the earlier version from this snippet's history, or --rev), disable (switch it off there) or remove (delete it there) |
network Agency
Multisite only, with the Agency plan or its trial. See Network snippets. The commands work on the network's snippets whatever --url says.
wp snipfire network list [--status=<active|inactive>] [--format=<format>]
wp snipfire network get <id> [--field=<field>]
wp snipfire network create --title=<title> [options like create] [--required] [--active] [--porcelain]
wp snipfire network update <id> [options like update] [--[no-]required] [--active] [--inactive]
wp snipfire network enable <id>... [--skip-test]
wp snipfire network disable <id>...
wp snipfire network delete <id>...
wp snipfire network overrides [<id>] [--site=<id|address>] [--off|--on] [--format=<format>]
wp snipfire network safe-mode [on|off]
create and update take the same options as the site commands, except the site-only ones: testing mode, cookie consent, schedules, the CSS-selector location (--selector, --selector-insert, --selector-match) and --replace-values (--values always changes only the keys you give). --required stops sites from switching the snippet off for themselves. enable test-loads the main site and up to two others. overrides lists which sites switched which network snippets off, or, with --site and --off or --on, changes one site's choice. safe-mode shows, switches on or switches off network safe mode.
wp snipfire network create --title="Shop banner" --type=html --hook=wp_body_open \
--conditions='[[{"type":"site","op":"is","value":["2","3"]}]]' --file=banner.html --active
wp snipfire network overrides 3 --site=example.com/shop --off Something unclear or missing? Tell us