WP-CLIwp easy-svg icons list

wp easy-svg icons list

List every icon collection on the site with label, icon count, origin and number of problem files, straight from the shell for audits and deploy checks.

WP-CLI command · Easy SVG Pro · Status: Stable

This command shows you every icon collection the site knows about, in one table. You see the slug you use in templates, the label, how many icons it holds, where it came from and how many files could not be used. It is the quickest way to answer "which icons does this site actually have?" without opening wp-admin.

Usage

wp easy-svg icons list

The command takes no arguments and no options. The output is always a table.

When to use it

  • After a deploy, to confirm that the theme folder or a drop-in folder registered the collection you expected, with the expected number of icons.
  • In an agency audit across many sites, to see which collections each site carries and where they come from (theme, drop-in folder, icon set, code).
  • To spot a broken folder: a problems count above zero means files on disk did not make it into the collection.
  • To find the exact collection slug to use in easy_svg_icon( 'slug/icon' ) or in wp easy-svg pack export.

Do not use it when:

Parameters

This command has no parameters and no options.

Return value

stdouttable

One row per collection with the columns collection, label, count, origin and problems, sorted by collection slug. For every row with problems above zero a hint line follows, for example acme: run wp easy-svg icons problems to see why.

exit codeint

0 when the table was printed. 1 when the licence is not active or the WP-CLI feature is off.

Default

Without arguments the command lists everything in the pack index: the free icon library, published icon sets and folder sources.

Examples

See what the site has

wp easy-svg icons list
+------------+-------------+-------+---------------------+----------+
| collection | label       | count | origin              | problems |
+------------+-------------+-------+---------------------+----------+
| acme       | ACME Icons  | 48    | dropin acme         | 0        |
| easy-svg   | Icons       | 12    | library             | 0        |
| theme      | Theme icons | 20    | theme acme-theme    | 2        |
+------------+-------------+-------+---------------------+----------+
theme: run `wp easy-svg icons problems` to see why.

Check a deploy before you call it done

#!/usr/bin/env bash
set -euo pipefail

# Fail the deploy when the theme collection is missing after the release.
if ! wp easy-svg icons list | grep -qE '^\| theme '; then
	echo "The theme icon collection did not register." >&2
	exit 1
fi

Audit every site of a multisite network

for url in $(wp site list --field=url); do
	echo "== $url"
	wp easy-svg icons list --url="$url" || echo "Easy SVG Pro CLI not available on $url"
done

Defensive: only run where the command can work

if wp plugin is-active easy-svg-pro && wp plugin is-active easy-svg; then
	wp easy-svg icons list
else
	echo "Easy SVG Support and Easy SVG Pro must both be active." >&2
fi

How it works

  1. The guard runs first. It asks one question: is the licence active and is the WP-CLI feature switched on under Icons → Features? If not, the command stops with Turn on WP-CLI under Icons → Features (a license is required). There is no capability check, because WP-CLI runs without a logged in user.
  2. The rows come from the pack index, the same inventory the Packs tab and every picker use. That is why the free icon library shows up here as easy-svg.
  3. Each source in that index only exists while its own feature is on. Icon sets appear only while the Icon set editor feature is on, and theme and drop-in folders only while Theme & folder sources is on. With a feature off, its collections are missing from the table even though the files or posts still exist.
  4. count is the number of icons that collection holds. origin is a short line such as library, set, theme acme-theme, dropin acme or plugin acme-icons. When a child theme overrides icons of its parent it reads like theme child > parent, and an imported set adds how it was made, for example set ACME (import-cli).
  5. problems counts files a source folder could not use. A folder whose manifest is broken registers no collection at all, but it still gets a row with count 0, so a broken folder is never invisible.

Folder scans are cached in a transient per folder for a day and are rebuilt when a file, the manifest or the free plugin's sanitizer changes, so this command is cheap to run often.

Pitfalls

  • A missing feature looks like missing icons. If theme or your icon sets are not in the table, check under Icons → Features first. The command does not tell you that a feature is off.
  • No other format. There is no --format option here. Parsing the ASCII table in scripts works, but wp easy-svg pack list --format=json is the safer source for automation.
  • An icon set can be listed twice. With both Multiple collections and Icon set editor on, older sites may carry a set under a slug with a -x suffix. Always copy the slug from this table, not from the set's post slug.
  • The hint lines go to stdout too. If you pipe the output, filter the lines that start with |.