wp easy-svg pack export
Write one icon collection out as a pack ZIP with manifest.json and one SVG per icon, ready to import on another site or to unzip into a drop-in folder.
WP-CLI command · Easy SVG Pro · Status: Stable
A pack is an icon collection as one file: a ZIP with a manifest.json and one SVG per icon. This command writes such a ZIP for any collection on the site, whatever made it: an icon set, a theme folder, a drop-in folder or the free icon library. You can import the file on another site or unzip it into wp-content/easy-svg-icons/<slug>/.
Usage
wp easy-svg pack export <collection> [--file=<path>]
When to use it
- You built an icon set on staging and want the same set on production or on another client's site.
- You want a backup of a collection as a file you can keep in Git.
- You want to turn an icon set from the database into files that a theme ships.
Parameters
The collection slug, exactly as wp easy-svg pack list prints it.
Where to write the ZIP. Relative paths start in the directory WP-CLI runs in. An existing file at that path is overwritten.
Return value
Success: 48 icons written to acme.zip.
0 when the file was written. 1 when the licence or the WP-CLI feature is off, the PHP extension ZipArchive is missing, the slug is unknown, or the file cannot be written.
Default
--file=<collection>.zip in the current directory.
Examples
Export one set
wp easy-svg pack export acme --file=acme.zip
Move a set from staging to production
#!/usr/bin/env bash
set -euo pipefail
wp @staging easy-svg pack export acme --file=/tmp/acme.zip
scp /tmp/acme.zip prod:/tmp/acme.zip
wp @production easy-svg pack import /tmp/acme.zip --as=acme
Ship a set with your theme
wp easy-svg pack export acme --file=/tmp/acme.zip
mkdir -p wp-content/themes/acme-theme/assets/icons
unzip -o /tmp/acme.zip -d wp-content/themes/acme-theme/assets/icons
The manifest's slug would then name the theme collection acme. Drop the slug line from manifest.json if the theme collection should keep its default name theme.
Defensive: check ZipArchive and the slug first
if ! php -m | grep -qi '^zip$'; then
echo "PHP zip extension missing on this host." >&2
exit 1
fi
wp easy-svg pack export acme --file="backups/acme-$(date +%F).zip" || {
echo "Export failed. Run: wp easy-svg pack list" >&2
exit 1
}
How it works
- Guard: licence and WP-CLI feature.
- ZipArchive must be available, otherwise the command stops before reading anything.
- The slug is looked up in the pack index. An unknown slug stops with
No collection called acme. Try: wp easy-svg pack list. - For every icon the command collects the label and the keywords and writes the stored, sanitized markup as
<icon>.svg. - The
manifest.jsongets the collectionslugandlabel, every icon withlabelandkeywords, and four fixed fields:
| Field | Value |
|---|---|
license | UNLICENSED |
author | The host of home_url(), for example example.com |
source | home_url() |
generator | easy-svg-pro plus the installed version |
- The ZIP is written with ZipArchive in create and overwrite mode. File names are reduced to their base name, so the archive is always flat.
Pitfalls
- The licence field is always UNLICENSED. A pack exported from a set that came with a CC BY or MIT notice does not carry that notice into the new manifest. Edit
license,authorandsourcein the exportedmanifest.jsonbefore you share the pack. - Silent overwrite. An existing file at
--fileis replaced without asking. - Relative paths follow the shell. With
--pathor an alias the ZIP is still written relative to your current directory on the machine where WP-CLI runs, which for@remotealiases is the remote server. - Keywords travel, but not everywhere. Keywords are in the manifest. A pack imported as an icon set loses them again, a pack unzipped into a folder keeps them.