easy-svg-pro/v1/packs/import-link
Fetches a share link made on another site and imports its pack as a new icon set, every icon sanitized and hardened.
REST endpoint, Easy SVG Pro, Status: Public, defined in includes/packs/share-links.php
Usage
POST /wp-json/easy-svg-pro/v1/packs/import-link
Example
curl -u admin:app-password -H 'Content-Type: application/json' -d '{"url":"https://other.example/wp-json/easy-svg-pro/v1/share/3f9a0c1b2d4e.Qm9yZWQgeWV0PyBUaGlzIGlzIG5vdCBhIHJlYWwgc2VjcmV0Lg"}' https://example.com/wp-json/easy-svg-pro/v1/packs/import-link
Description
The import side of share links, the same as pasting a link on the Templates screen. First the same checks as an upload in packs/import: 409 easy_svg_pro_no_editor when Collections is off, 409 easy_svg_pro_no_sanitizer when Easy SVG is inactive, 409 easy_svg_pro_no_hardener when it is too old to harden icons.
Then the address. Only another site's share route is fetched: https, port 443 if a port is given, no user name, password or fragment, a host name (never an IP address, never a single label such as localhost), and a path ending in /wp-json/easy-svg-pro/v1/share/<token> with no query, or the plain permalink form ?rest_route=/easy-svg-pro/v1/share/<token>. Anything else answers 400 easy_svg_pro_share_bad_link.
The fetch: every A and AAAA address of the host must be public, else nothing is sent. The connection is pinned to the checked address with cURL against DNS rebinding, so PHP needs cURL. Redirects are not followed, the timeout is 15 seconds, the answer may be at most 16 MB and must be a ZIP with status 200. A refused fetch answers easy_svg_pro_share_fetch: 404 when the other site said 404 (expired, revoked, or sharing off there), else 400.
The ZIP is then imported exactly like an upload: every icon is sanitized and hardened, the pack becomes a new set and never merges into an existing one, a bundle becomes one set per pack. When the slug is taken and no slug was sent, nothing is written: the answer has collision: true, imported: 0 and a free slug to send back. A sent slug that is taken is stored under the next free variation. Other refusals: 422 easy_svg_pro_empty_pack, 409 easy_svg_pro_no_slug, 500 easy_svg_pro_share_tmp or easy_svg_pro_set_failed.
Permission: manage_options, an active license, the icon library of the free plugin switched on and the Share links feature (share_links) switched on under Settings, Features. WordPress checks the required arguments before the permission callback, so a request without them answers 400, even from a guest.
Parameters
The share link from the other site.
The collection slug to import under, when the one in the manifest is taken. Made into a slug first.
Return value
The answer of a pack import: slug, wanted, label, id, imported, refused, collision, license, author, style and truncated. A bundle answers bundle: true with one row per pack in packs.
Response
{
"slug": "acme",
"wanted": "acme",
"label": "ACME",
"id": 57,
"imported": 48,
"refused": [],
"collision": false,
"license": "MIT",
"author": "ACME Inc.",
"style": null,
"truncated": false
}