easy-svg-pro/v1/quick-insert/icon
Creates a free library icon from pasted or dropped SVG markup and adds it to the recent list.
REST endpoint · Easy SVG Pro · Status: Internal · Defined in includes/editor/quick-insert.php
Usage
POST /wp-json/easy-svg-pro/v1/quick-insert/icon
Example
curl -X POST "https://example.com/wp-json/easy-svg-pro/v1/quick-insert/icon" \
-H "X-WP-Nonce: $NONCE" -b "$COOKIES" \
-H "Content-Type: application/json" \
-d '{"label": "Rocket", "markup": "<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l4 8H8z"/></svg>"}'
Description
Stores the markup through the free plugin's own add function, so it meets the same sanitizer an upload does, and returns the reference the editor inserts. Needs the free plugin's store capability, edit_theme_options by default, not just edit_posts. Answers 409 easy_svg_pro_no_store when the free icon library is off.
Permission: The free plugin's icon capability (EASY_SVG_ICON_CAP, edit_theme_options by default) and an active licence with Quick insert switched on.
Parameters
The SVG markup. Sanitized and hardened on the way in, whatever is sent.
The icon name a person reads. The slug is derived from it once and never moves.
Return value
{icon, label, state} where icon is the new reference and state has the shape of GET /quick-insert/state. 400 easy_svg_pro_no_label, 422 easy_svg_pro_add_failed with the free plugin's own sentence, 422 easy_svg_pro_no_name.
Response
{icon, label, state} where icon is the new reference and state has the shape of GET /quick-insert/state. 400 easy_svg_pro_no_label, 422 easy_svg_pro_add_failed with the free plugin's own sentence, 422 easy_svg_pro_no_name.
{
"icon": "easy-svg/rocket",
"label": "Rocket",
"state": {
"recent": [
"acme/arrow"
],
"favourite": [
"easy-svg/heart"
],
"can_create": true
}
}