array(
'class' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'aria-hidden' => true,
'role' => true,
'focusable' => true,
),
'path' => array(
'fill' => true,
'fill-rule' => true,
'd' => true,
'transform' => true,
),
'circle' => array(
'cx' => true,
'cy' => true,
'r' => true,
),
'polygon' => array(
'fill' => true,
'fill-rule' => true,
'points' => true,
'transform' => true,
'focusable' => true,
),
);
/**
* SVG icons.
*
* @var string[]
*/
public static $icons = array(
'calendar-fill' => '',
'comment' => '',
'eye' => '',
'heart-fill' => '',
'user' => '',
'edit' => '',
'tag' => '',
'home' => '',
'arrow-left' => '',
'arrow-right' => '',
'arrow-left-long' => '',
'arrow-right-long' => '',
'bars' => '',
'x-mark' => '',
'random-fill' => '',
'permalink' => '',
);
/**
* Get the SVG icon.
*
* @param string $icon Default is empty.
* @param bool $echo Default is true.
* @param array $args Default is empty.
*
* @return string|null
*/
public static function get_svg( $icon = '', $echo = true, $args = array() ) {
$icons = self::get_icons();
$atts = '';
$svg = '';
if ( ! empty( $args ) ) {
foreach ( $args as $key => $value ) {
if ( ! empty( $value ) ) {
$atts .= esc_html( $key ) . '="' . esc_attr( $value ) . '" ';
}
}
}
if ( array_key_exists( $icon, $icons ) ) {
$repl = sprintf( '\s*', '><', $svg );
}
if ( ! $svg ) {
return null;
}
if ( $echo ) {
echo wp_kses( $svg, self::$allowed_html );
} else {
return wp_kses( $svg, self::$allowed_html );
}
}
/**
* Get all SVG icons.
*
* @return mixed|void
*/
public static function get_icons() {
/**
* Filter for svg icons.
*
* TODO: @since.
*/
return apply_filters( 'coloramg_svg_icons', self::$icons );
}
}
}