Constantseasy_svg_pro_config

easy_svg_pro_config

Fix Easy SVG Pro switches and settings from code, per site, on top of easy-svg-pro.json: every key the filter returns is locked on the screens and in every write.

Filter, Easy SVG Pro, Status: Stable

Easy SVG Pro can take its feature switches and its settings from a file, wp-content/easy-svg-pro.json. This filter has the last word after that file: it receives what the file fixes and returns what is fixed on this site. Use it when the decision needs PHP, for example per site of a multisite network.

Usage

apply_filters( 'easy_svg_pro_config', array $config, int $site_id )

Applied in includes/core/config.php, inside pro_config(), once per request and site.

When to use it

  • One policy for many sites that a JSON file cannot express, for example by blog ID or by host name.
  • A must-use plugin that locks a switch, so nobody turns it on or off in wp-admin.

Do not use it when:

  • A static file is enough. easy-svg-pro.json (or the file named by EASY_SVG_PRO_CONFIG) needs no code.
  • You want to change the free plugin's settings. They are read before Easy SVG Pro loads.

Parameters

body
$configarray
Required

array( 'features' => array(...), 'settings' => array(...) ): what the file fixes for this site, base values with the environments.<type> block for wp_get_environment_type() on top. Feature keys arrive under their current names (sets, templates, share_links and the others); an older key the file used is already mapped, so $config['features']['editor'] is not set, read sets.

body
$site_idint
Required

get_current_blog_id(), so a network can answer per site.

Return value

returnarray

The same shape. Only features and settings are read, and both are cleaned again with the rules the file meets: a feature must be a known key with true or false, a setting a known key (tags_enabled boolean; extra_tags, extra_attrs, blocked_tags, blocked_attrs a list or a string), and dangerous names are dropped from the extra lists. Older feature keys you return (editor, sources, collections, presets, fontawesome, icon_field) are still mapped to the switch they became. Anything else lands in unknown.

Default

What the file fixes, or array( 'features' => array(), 'settings' => array() ) when there is no file.

Examples

add_filter(
	'easy_svg_pro_config',
	function ( $config ) {
		$config['features']['cli']         = true;
		$config['features']['share_links'] = false;

		return $config;
	}
);

Per site of a network

function acme_icon_policy( $config, $site_id ) {
	// The brand portal (blog 3) may install ready-made sets, nobody else.
	$config['features']['templates'] = ( 3 === (int) $site_id );

	return $config;
}
add_filter( 'easy_svg_pro_config', 'acme_icon_policy', 10, 2 );

How it works

  1. pro_config() reads the file once per request and site, at most 64 KB, and cleans it.
  2. This filter runs with the cleaned features and settings.
  3. The result is cleaned again. Every key left is locked: pro_features() and pro_settings() return it on top of what the site stored, and the write paths (pro_features_write(), pro_settings_write(), the Features and Settings routes, the abilities and quick setup profiles) leave it alone and name it under locked.
  4. A fixed tags_enabled also locks the tags switch.

The license still decides: a feature fixed to true runs only while the license is active.

Pitfalls

  • Nothing is stored. Remove the filter and the site falls back to what it had stored.
  • Return the array. A callback that returns nothing turns the result into null, which is ignored, so only the file applies.
  • wp easy-svg config shows the result. Run it to see what is fixed and what the site stored underneath.