'',
'arrow-right' => '',
'calendar' => '',
'check' => '',
'check-circle' => '',
'chevron-down' => '',
'clock' => '',
'coin' => '',
'copy' => '',
'flag' => '',
'flame' => '',
'gift' => '',
'info' => '',
'lock' => '',
'mail' => '',
'map' => '',
'medal' => '',
'share' => '',
'star' => '',
'ticket' => '',
'trending-up' => '',
'trophy' => '',
'users' => '',
'wallet' => '',
'x' => '',
);
/**
* Sanitized markup, cached per name and class.
*
* @var array
*/
private static $cache = array();
/**
* Get an icon's markup.
*
* @param string $name Icon name.
* @param string $class Extra class names.
* @return string Sanitized SVG markup, or an empty string for an unknown name.
*/
public static function get($name, $class = '')
{
if (! isset(self::$paths[$name])) {
return '';
}
$key = $name . '|' . $class;
if (! isset(self::$cache[$key])) {
$classes = trim('gameengine-icon ' . $class);
$svg = '';
self::$cache[$key] = wp_kses($svg, self::allowed_html());
}
return self::$cache[$key];
}
/**
* Print an icon.
*
* @param string $name Icon name.
* @param string $class Extra class names.
*/
public static function render($name, $class = '')
{
echo self::get($name, $class); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sanitized by wp_kses() in get().
}
/**
* The SVG elements and attributes an icon may use.
*
* @return array
*/
public static function allowed_html()
{
$shape = array(
'd' => true,
'cx' => true,
'cy' => true,
'r' => true,
'rx' => true,
'ry' => true,
'x' => true,
'y' => true,
'width' => true,
'height' => true,
'points' => true,
'fill' => true,
'stroke' => true,
'stroke-width' => true,
);
return array(
'svg' => array(
'class' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'fill' => true,
'stroke' => true,
'stroke-width' => true,
'stroke-linecap' => true,
'stroke-linejoin' => true,
'aria-hidden' => true,
'focusable' => true,
),
'path' => $shape,
'circle' => $shape,
'rect' => $shape,
'ellipse' => $shape,
'polyline' => $shape,
);
}
}