Iconseasy_svg_add_icon_result()

easy_svg_add_icon_result()

Stores one icon and returns its state, id and the slug it actually got.

Function · Easy SVG · Status: Internal · Defined in includes/icon-manager.php

Internal: not part of the promised public surface. It may change without notice.

Usage

easy_svg_add_icon_result( string $label, string $markup ): array

Example

$result = easy_svg_add_icon_result( 'Arrow right', $svg );
if ( 'added' === $result['state'] && $result['slug'] !== $result['wanted'] ) {
	// The name was taken.
}

Description

Sanitizes and hardens the markup through easy_svg_accept_icon() with the upload bounds, inserts an esw_icon post with kses off for that insert, and deletes it again if what was stored has no svg. WordPress makes post_name unique, so a second Arrow becomes arrow-2; wanted carries the slug that was asked for. States: added, no_sanitizer, bad_name, empty, too_large, too_complex, not_svg, not_saved.

Parameters

body
$labelstring

Icon name, already sanitized as text. The slug is derived from it.

body
$markupstring

Raw SVG markup.

Return value

returnarray{state:string, id:int, slug:string, wanted?:string}

wanted is present only when added.

Not part of the promised surface and does not check capabilities.