wp easy-svg fa apply
Make an icon set from a recipe JSON and a Font Awesome download: the same 20 to 60 icons on every client site, in one command.
WP-CLI command, Easy SVG Pro, Status: Stable
A recipe names the Font Awesome icons a site needs, by style and name. This command reads those icons out of a Font Awesome download (Free or Pro) and stores them as one icon set. It is the command-line twin of Load recipe under Single icons in the Font Awesome import on the Templates screen.
Usage
wp easy-svg fa apply <recipe> --zip=<file> [--as=<slug>] [--strict]
When to use it
- You set up client sites with a script and want the same icons on each.
- Font Awesome released a new version and you want the set rebuilt from the new download.
- An AI assistant wrote a recipe for you and you want to apply it without opening wp-admin.
Parameters
Path to the recipe JSON.
The Font Awesome download to take the icons from, as fontawesome.com hands it out. Do not unzip it.
Register the set under this slug instead of one made from the recipe's name. It is turned into a slug first.
Write nothing when the download lacks an icon the recipe names.
The recipe
{
"version": 1,
"name": "Dental practice",
"icons": {
"light": ["tooth", "phone", "calendar"],
"duotone": ["tooth"]
}
}
| Field | Meaning |
|---|---|
version | Always 1. Anything else is refused. |
name | The set's label. Its slug is made from it unless you pass --as. Empty means "Font Awesome". |
icons | An object: Font Awesome style => list of icon names. Not empty. |
Style keys and icon names must match ^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$: lowercase letters, digits, dashes and underscores, no slashes. A recipe that breaks this is refused as a whole and nothing is written. A name listed twice in one style is read once.
Icon names in the set: an icon keeps its Font Awesome name. A name that is already taken in the set gets the style appended (tooth-duotone), then a number (-2, -3).
Return value
Warning: duotone/ghost is not in this download. for each missing icon, then Success: 3 icons imported as dental-practice.
0 when the set was stored. 1 when the license, the free plugin's icon library, the WP-CLI feature or the Templates feature is off, a file cannot be read, the recipe is invalid, the free Easy SVG plugin is not active, --strict met a missing icon, no icon could be accepted, the name or --as leaves no usable slug, the slug is taken without a free variation, or the set could not be stored.
Examples
Apply a recipe
wp easy-svg fa apply dental.json --zip=~/Downloads/fontawesome-pro-7.1.0-web.zip
Same set on every client site, fail loudly
for site in @client-a @client-b @client-c; do
wp "$site" easy-svg fa apply dental.json --zip=fa.zip --as=dental --strict
done
How it works
- Guard: license, WP-CLI feature, Templates feature (
Turn on Templates on the Features screen of Easy SVG.). - The recipe is parsed and checked; the ZIP is opened with ZipArchive.
- Only the ZIP's listing is read, then only the files the recipe names, from
svgs/<style>/<name>.svg. A Pro download is hundreds of megabytes, so it is never unpacked. - Each file above the free plugin's SVG size limit is skipped; the rest are sanitized and hardened like any upload.
- The set is stored with the download's origin: CC BY 4.0 for Free, the Font Awesome Pro license for Pro, credited to Fonticons, Inc., with the version.
Pitfalls
- A taken slug moves aside. If the slug exists, the set is stored under a free variation and a warning names it. Pass
--asto choose. - Missing icons only warn. Without
--strict, a recipe written for a newer Font Awesome still imports what the download has. - Collections decides visibility. The set is stored even with the Collections feature off, but it only registers as a collection while that feature is on.
- Only downloads. A Font Awesome kit code has no files. Pro downloads exist only with the annual Solo and Team plans.