wp easy-svg icons problems
Name every file a theme, drop-in or registered icon folder could not use, with the reason, so you can fix the file instead of guessing why an icon is missing.
WP-CLI command · Easy SVG Pro · Status: Stable
When an icon you put into a folder does not show up, this command tells you why. It prints one row per refused file with the collection, the folder, the file name, the icon name and the reason. If nothing was refused, it says so in one line.
Usage
wp easy-svg icons problems
No arguments, no options. Output is a table, or a success message when every folder registered everything it holds.
When to use it
wp easy-svg icons listshows aproblemscount above zero.- A designer added SVGs to the theme's
assets/iconsfolder and some of them do not appear in the inserter. - A whole drop-in collection is missing. A broken
manifest.jsonregisters nothing and is reported here with one row. - As a CI or post-deploy check: an empty result means every file in every source folder is in use.
Do not use it for icon sets or uploads. Sets are stored in the database and were already checked when they were saved. To check a folder before it goes live, use wp easy-svg icons validate.
Parameters
This command has no parameters and no options.
Return value
One row per refused file with the columns collection, source (the folder path), file, icon and reason. When nothing was refused: Success: Every source folder registered everything it holds.
0 in both cases. 1 when the licence is not active or the WP-CLI feature is off.
Default
Covers every source folder scanned on this request: the active theme (parent and child), every drop-in folder under wp-content/easy-svg-icons and every directory passed to easy_svg_register_icon_collection().
Examples
Find out why icons are missing
wp easy-svg icons problems
+------------+---------------------------------------+------------------+-----------+--------------+
| collection | source | file | icon | reason |
+------------+---------------------------------------+------------------+-----------+--------------+
| acme | /var/www/wp-content/easy-svg-icons/acme | phone.svg | phone | not-svg |
| brand | /var/www/wp-content/easy-svg-icons/brand | manifest.json | | manifest-invalid |
+------------+---------------------------------------+------------------+-----------+--------------+
Fail a deploy when a folder lost icons
The command exits 0 either way, so check the output instead of the exit code:
out="$(wp easy-svg icons problems)"
if ! grep -q '^Success:' <<<"$out"; then
echo "$out"
echo "Some icon files are not in use. Fix them before going live." >&2
exit 1
fi
Collect reports from every client site
for path in /var/www/clients/*/public; do
echo "== $path"
wp --path="$path" easy-svg icons problems 2>&1 || true
done > icon-problems-report.txt
How it works
Every source folder is scanned on init at priority 9 while Theme & folder sources is on. Each file the scan cannot use is recorded for its collection, before the collection is registered. That record is what this command prints. It is the same list the Packs tab shows under a collection.
The reasons you can meet. Every one of them is reported for a folder with a manifest.json (the files the manifest names). A folder without a manifest only reports too-many, see Pitfalls.
| Reason | What it means |
|---|---|
manifest-invalid | manifest.json is not valid JSON, is a list, has no icons or an empty icons. The whole folder registers nothing. |
unsupported-version | The manifest declares a schema version newer than this plugin reads. The whole folder registers nothing. |
bad-name | The file name or the manifest name does not make a valid icon slug. |
duplicate | Two entries end up with the same icon name. The first one wins. |
outside-folder | The manifest points at a file outside the folder, or a symlink leaves it. |
too-large | The file is larger than easy_svg_pro_source_file_max_bytes (2 MB by default). |
too-many | The folder holds more icons than easy_svg_pro_source_max_icons (1000 by default); these files were never read. |
unreadable | The file is empty or could not be read. |
not-svg | The sanitizer refused the file. |
no-drawing | After sanitizing and hardening nothing drawable is left. |
Pitfalls
- Exit code 0 is not "all good". Both a clean result and a table of problems exit
0. Script on theSuccess:line. - A feature that is off reports nothing. With Theme & folder sources off no folder is scanned, so the result is the success message although the folders may be full of broken files.
- Folders without a manifest are mostly quiet. A folder with no
manifest.jsononly reportstoo-many. A file that is too large, unreadable, refused by the sanitizer, empty after hardening, badly named or a duplicate is skipped without a row. Add amanifest.json, or runwp easy-svg icons validateon the folder, to see a verdict per file. - Results follow the cache. Scans are cached per folder and rebuilt when a file or the manifest changes. A fix shows up as soon as the file's modification time changes.