wp easy-svg network share
Share an icon set of the main site with every site of a multisite network, or with the sites named. Multisite only.
WP-CLI command, Easy SVG Pro, Status: Stable
On a multisite network, the main site can hand its icon sets to the other sites. This command shares one set, with every site or with the sites you name. The other sites read the shared sets from one network option and never touch the main site's tables. While a set is shared, only a network administrator may change it on the main site.
Usage
wp easy-svg network share <set-id> [--sites=<sites>]
When to use it
- An agency runs a network for one client and wants the brand icons on every site.
- A new site joined the network and should get the house set.
Parameters
The post id of the icon set (post type easy_svg_set) on the main site. The help points at wp easy-svg pack list, which prints slugs, not ids: get the id with wp post list --post_type=easy_svg_set --fields=ID,post_title,post_name.
all, or site ids separated by commas, for example 2,5. Ids that are not positive whole numbers are dropped; if none is left, the command stops with Pass --sites=all or site ids separated by commas.
Return value
Success: Shared with all sites. or Success: Shared with sites 2, 5. On a German site: Mit allen Websites geteilt. or Mit den Websites 2, 5 geteilt.
0 when the choice was stored. 1 when the license, the free plugin's icon library or the WP-CLI feature is off, the command does not run on the main site of a multisite network (Network sets are shared from the main site of a multisite network. Pass --url=<main site>.), the Collections feature is off, the id is not an icon set (Set not found.) or --sites holds no valid id.
Default
--sites=all.
Examples
Share with the whole network
wp easy-svg network share 42 --url=https://network.example
Share with two sites
wp easy-svg network share 42 --sites=2,5 --url=https://network.example
How it works
- Guard: license and WP-CLI feature, then the main site of a multisite network, then the Collections feature.
- The choice is stored on the set in the post meta
_easy_svg_pro_network. Sharing again replaces the earlier choice. - The network copy in the site option
easy_svg_pro_network_setsis rebuilt from every published set that carries the meta. Every other site reads only that option.
Pitfalls
- Run it on the main site. WP-CLI runs on the main site unless
--urlor theurlinwp-cli.ymlpoints at another site. There the command stops. Pass--url=<main site>when in doubt. - Only published sets travel. A draft or trashed set can be marked as shared, but it is not written into the network copy.
- Site ids are not checked. An id of a site that does not exist is stored as given and never matches.
- The plan decides. On a multisite network the Pro tools need the Unlimited plan. With another plan the guard refuses as if the WP-CLI feature were off.
- Shared sets are guarded. While shared, a write to the set on the main site needs
manage_network_options: a REST write by anyone else answers 403easy_svg_pro_network_set, and the post capabilities ask for the same.