REST APIeasy-svg-pro/v1/library/copy

easy-svg-pro/v1/library/copy

Copies up to 25 icons into the icon library or into a set. The source is never changed.

REST endpoint, Easy SVG Pro, Status: Public, defined in includes/core/rest/library.php

Usage

POST /wp-json/easy-svg-pro/v1/library/copy

Example

curl -u admin:app-password -H 'Content-Type: application/json' -d '{"refs":["brand/arrow"],"to":"easy-svg"}' https://example.com/wp-json/easy-svg-pro/v1/library/copy

Description

A copy, never a move: the source keeps its icon and no page is rewritten. to is easy-svg for the icon library or the collection slug of a set.

Into the icon library each icon goes through the free plugin's own write path (easy_svg_add_icon_result()), so its sanitizer and limits apply and a taken name gets a numbered suffix; the row then carries the new attachment id and, when the name was taken, wanted. 409 easy_svg_pro_no_store when the icon library is off or the free plugin is too old.

Into a set the icons are sanitized, hardened and merged; a name the set already holds reports exists. Copying into a set needs the Collections feature, else 403 easy_svg_pro_not_writable. A target that is no set answers 400 easy_svg_pro_not_writable. 409 easy_svg_pro_no_hardener when the free plugin is too old.

Every copy remembers where it came from in the post meta _easy_svg_pro_copied_from: the source ref, its kind, its name and the time.

Permission: permission_callback is rest_permission_licence(): manage_options and an active license. A network whose plan does not cover multisite answers 403 easy_svg_pro_tools_locked. WordPress checks the required parameters before the permission callback, so a request that lacks one answers 400 rest_missing_callback_param, a guest's request too, not 401.

Parameters

body
refsarray<string>
Required

The icons to copy, as collection/slug. Past 25 the rest report over_limit.

body
tostring
Required

Where the copies go: easy-svg for the icon library, or a set by its collection slug.

Return value

returnWP_REST_Response|WP_Error

to, set_id (set target only) and rows, per ref a state: copied, exists, same, name_clash, no_markup, refused (library target, with reason), over_limit or invalid.

Response

{
  "to": "easy-svg",
  "rows": [
    {
      "ref": "brand/arrow",
      "state": "copied",
      "to_ref": "easy-svg/arrow",
      "id": 318
    }
  ]
}