Developer guidesCentral configuration

Central configuration

easy-svg-pro.json, the EASY_SVG_PRO_CONFIG constant and the easy_svg_pro_config filter: format, precedence, validation, what the REST answers and WP-CLI show.

Every Pro switch (easy_svg_pro_features) and every Pro setting (easy_svg_pro_settings) can be fixed from outside the database: in a JSON file that ships with your deploy, and in a PHP filter. A fixed key cannot be changed in wp-admin, and nothing is written to the database, so removing the file gives every site its own values back.

Try it

Create wp-content/easy-svg-pro.json:

{ "features": { "cli": true, "sets": true } }

What you see: under Easy SVG → Settings → Features, WP-CLI and Collections are on and locked with Fixed by configuration. On the command line:

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

value is what is in force, stored what the site has saved itself.

Sources, in order

WinsSource
1easy_svg_pro_config filter, ( array $config, int $site_id )
2environments.<type> in the file, by wp_get_environment_type()
3The file's base features and settings
4What the site stored

The file is WP_CONTENT_DIR . '/easy-svg-pro.json', or the path in the constant EASY_SVG_PRO_CONFIG. It is read once per request and site, at most 64 KB.

Format

{
  "features": { "templates": false, "sets": true },
  "settings": { "tags_enabled": true, "extra_tags": ["foreignObject"], "extra_attrs": ["data-name"] },
  "environments": {
    "local": { "features": { "templates": true } },
    "staging": { "settings": { "tags_enabled": false } }
  }
}
KeyAccepted
features.<flag>one of the 21 switches (tags, sets, cli, abilities, templates, share_links, blocks, quick_insert, twig, icon_field_blocks and the integration switches icon_field_acf, icon_field_scf, icon_field_lazyblocks, elementor, metabox, wpbakery, salient, uncode, impreza, avada, generateblocks), true or false only. Older keys (editor, sources, collections, presets, fontawesome, icon_field) are still accepted and set the switch they became. Not named, salient and uncode follow wpbakery, icon_field_scf follows icon_field_acf
settings.tags_enabledtrue or false
settings.extra_tags, settings.extra_attrsa list of names or one string; dangerous names are dropped exactly as on save
settings.blocked_tags, settings.blocked_attrsa list of names or one string; they only narrow the allow-list
environments.<type>local, development, staging, production with features and settings

Anything else is ignored and listed in config.unknown. Broken JSON, a list instead of an object, an unreadable or too large file: the whole file is ignored and config.error is invalid_json, not_object, unreadable or too_large.

The filter gets { features, settings } after the file, with feature keys under their current names, and must return the same shape; its result is cleaned again with the same rules.

Effect

  • pro_features() and pro_settings() return the stored values with the configuration on top. feature_on() still needs an active license.
  • Writes go through pro_features_write() / pro_settings_write() with the locked keys removed, so a configured value is never stored.
  • A fixed tags_enabled also locks the tags switch.
  • Quick setup profiles skip locked flags.

Abilities

easy-svg-pro/get-features and easy-svg-pro/get-settings answer with:

"config": {
  "path": "/var/www/html/wp-content/easy-svg-pro.json",
  "file": true,
  "error": "",
  "message": "",
  "unknown": [],
  "locked": { "features": ["sets", "tags", "templates"], "settings": ["tags_enabled"] }
}

update-features and update-settings answer the same, plus locked: the keys of the request that were left alone.

WP-CLI

wp easy-svg config
wp easy-svg config --format=json

Columns key, value (in force) and stored (what the site has). An older key in the file is listed as the switch it became. A key that is not a switch, or has the wrong type, is a warning and ignored; features.bulk is named as always on, since bulk editing has no switch. A broken file is an error with a non-zero exit code. Read-only. Needs the WP-CLI switch, which the file itself may fix.

Not covered

The free plugin's easy_svg_settings is read before Pro loads. Fix those with a must-use plugin (a PHP file in wp-content/mu-plugins/ that WordPress always loads first): Global settings with per-site overrides.

Code

includes/core/config.php in Easy SVG Pro.

Next