easy-svg-pro/import-pack-from-link
Import a pack from a share link.
Ability · Easy SVG Pro · Defined in includes/abilities/manage.php
Usage
wp_get_ability( 'easy-svg-pro/import-pack-from-link' )->execute( array $input ): array|WP_Error
Example
<?php
$ability = wp_get_ability( 'easy-svg-pro/import-pack-from-link' );
if ( $ability ) {
$result = $ability->execute( array(
'url' => 'https://agency.example.com/wp-json/easy-svg-pro/v1/share/3f9a1c0b7d42.AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdE',
) );
if ( ! is_wp_error( $result ) && ! empty( $result['collision'] ) && 0 === $result['imported'] ) {
// Nothing was written: the slug was taken. Call again with the free slug the answer names.
$result = $ability->execute( array(
'url' => 'https://agency.example.com/wp-json/easy-svg-pro/v1/share/3f9a1c0b7d42.AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-AbCdE',
'slug' => $result['slug'],
) );
}
}
Description
Fetches a share link made on another site and imports it exactly as an upload. When the slug is taken, nothing is written and the answer names a free slug: call again with that slug.
Runs POST /wp-json/easy-svg-pro/v1/packs/import-link through rest_do_request(), so the route's own permission check, argument schema and handler do the work. The ability adds no write path of its own.
Registered while the AI agents (MCP) switch and the Share links feature are on.
Permission: the user needs manage_options and an active license, and every call asks the route's own check again.
Writes to the site.
The pack is stored as a new icon set, so the Collections feature must be on as well, else easy_svg_pro_no_editor (409). The fetch is refused before anything is written unless the link:
- starts with
https://, on port 443 if a port is given, with no user, password or#part, - names a host by name (no IP address, no single label such as
localhost) and every address that name resolves to is public, - points at another site's
/wp-json/easy-svg-pro/v1/share/<token>route (or?rest_route=to it).
A wrong link answers easy_svg_pro_share_bad_link (400). A fetch that fails answers easy_svg_pro_share_fetch: 404 when the link has expired, was revoked or sharing is off on the other site, 400 otherwise (private address, redirect, not a ZIP, over 16 MB, no cURL to pin the address). Redirects are never followed. Every icon is sanitized and hardened like an upload.
Parameters
Required. The share link from the other site.
Optional. The collection slug to import under, when the one in the manifest is taken.
Return value
An array on success, a WP_Error with the route's code and status on failure. The same answer as an upload on the Templates screen: slug, wanted, label, id, imported, refused, collision, license and author. When collision is true and imported is 0, nothing was stored and slug is the free slug to call again with.