WP-CLIwp easy-svg config

wp easy-svg config

Show which feature switches and settings the central configuration (easy-svg-pro.json or the easy_svg_pro_config filter) fixes on this site, next to what the site has stored.

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

An agency can fix switches and settings for many sites with one file, easy-svg-pro.json, or the filter easy_svg_pro_config. A fixed switch is locked on the Features screen and never stored. This command answers "why does my switch not stick?" in one table: the value the configuration puts in force beside the value the site has stored. It only reads.

Usage

wp easy-svg config [--format=<format>]

When to use it

  • After a deploy, to confirm the file was found and every key in it was understood.
  • A switch on the Features screen is greyed out and you want to know what fixes it.
  • Before you remove a key from the file, to see what the site falls back to: the stored column.

Parameters

query
--formatoption

table, json, csv or yaml.

Return value

stdouttable|json|csv|yaml

First a line naming the file: Configuration file: <path> or No configuration file at <path>. Then one line per older key in the file, Older key editor → sets, and a warning per key that is ignored: Ignored, no longer a switch, it is always on: features.bulk for features.bulk, else Ignored, not a known key or not the right type: <key>. Then one row per fixed key with the columns key (features.<key> or settings.<key>), value (in force) and stored (what the site has). When nothing is fixed: Success: Nothing is fixed by configuration; every switch is the site's own.

exit codeint

0 when the configuration was read, warnings included. 1 when the license, the free plugin's icon library or the WP-CLI feature is off, or the file is broken: not valid JSON, not one JSON object, larger than 64 KB or unreadable. The error names the reason and the path, for example The configuration file is not valid JSON. It is ignored until it is fixed. /var/www/wp-content/easy-svg-pro.json.

Default

--format=table. The file is wp-content/easy-svg-pro.json, or the path in the constant EASY_SVG_PRO_CONFIG.

Examples

What the configuration fixes here

wp easy-svg config
Configuration file: /var/www/wp-content/easy-svg-pro.json
+---------------+-------+--------+
| key           | value | stored |
+---------------+-------+--------+
| features.cli  | true  | false  |
| features.sets | true  | true   |
+---------------+-------+--------+

Fail a deploy on a broken file

wp easy-svg config --format=json > /dev/null || { echo "easy-svg-pro.json is broken" >&2; exit 1; }

How it works

  1. Guard: license and WP-CLI feature. A configuration that fixes features.cli to false therefore also turns this command off.
  2. The file is read: the top level features and settings, and under environments the block for the current wp_get_environment_type() (local, development, staging or production), which wins over the top level.
  3. The filter easy_svg_pro_config gets the result per site and may change it. Its answer is checked again, so it cannot set an unknown key.
  4. Feature keys must be known switches with true or false; older names such as editor, sources, collections, presets and fontawesome are accepted and fix the switch they became. Setting keys must be known settings, tags_enabled a boolean, the others a string or a list.
  5. The table shows the keys in force with the stored value beside them. Booleans print as true and false, lists joined with commas.

Pitfalls

  • Only Pro's switches and settings. The free plugin's settings are read before Pro loads and cannot be fixed by this file.
  • The environment block wins. A key under environments.production beats the same key at the top level on a production site. Check wp eval 'echo wp_get_environment_type();' when a value surprises you.
  • The file line comes first, also in JSON. Configuration file: ... and the older key lines are printed before the rows, on standard output, in every format. Skip them before you parse: wp easy-svg config --format=json | tail -n 1.
  • Unknown keys do not fail. A typo is only a warning and exit code 0. Read the warnings, or check them in CI.