%4$s',
esc_attr( $width ),
esc_attr( $height ),
esc_attr( $viewbox ),
$icons[ $name ],
esc_attr( $name ),
esc_attr( $id )
);
}
/**
* Echo an icon in a safe mode.
*
* @param string $name The name of the icon.
* @param int $width The width.
* @param int $height The height.
* @param string $viewbox The viewbox, will be auto-built from width and height if not set.
* @param string $id The id of the icon.
*
* @return void
*/
function wpcode_icon( $name, $width = 20, $height = 20, $viewbox = '', $id = '' ) {
$icon = get_wpcode_icon( $name, $width, $height, $viewbox, $id );
if ( ! empty( $icon ) ) {
echo wp_kses(
$icon,
wpcode_get_icon_allowed_tags()
);
}
}
/**
* Get the allowed tags for svg icons, to be used in wp_kses.
*
* @return array
* @see wpcode_icon()
* @see wp_kses()
*/
function wpcode_get_icon_allowed_tags() {
return array(
'svg' => array(
'class' => true,
'aria-hidden' => true,
'aria-labelledby' => true,
'role' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'id' => true,
),
'g' => array(
'fill' => true,
'clip-path' => true,
),
'title' => array( 'title' => true ),
'path' => array(
'd' => true,
'fill' => true,
'fill-rule' => true,
'clip-rule' => true,
'data-name' => true,
),
'circle' => array(
'cx' => true,
'cy' => true,
'r' => true,
'stroke' => true,
'stroke-width' => true,
'fill' => true,
),
'rect' => array(
'x' => true,
'y' => true,
'width' => true,
'height' => true,
'fill' => true,
),
'clipPath' => array(
'id' => true,
),
'defs' => array(),
);
}
/**
* Get the whole array of WPCode SVG icons.
*
* @return array
*/
function wpcode_icons() {
return (array) apply_filters(
'wpcode_icons',
array(
'logo' => '',
'logo-text' => '',
'auto' => '',
'shortcode' => '',
'copy' => '',
'check' => '',
'remove' => '',
'search' => '',
'close' => '',
'upload' => '',
'folder' => '',
'arrow' => '',
'file-text' => '',
'help' => '',
'inbox' => '',
'info' => '',
'success' => '',
'warning' => '',
'file' => '',
'support' => '',
'code' => '',
'filter' => '',
'split' => '',
'terminal' => '',
'error_badge' => '',
'php' => '',
'trash' => '',
'tags' => '',
'eye' => '',
'arrow-left' => '',
'rewind' => '',
'cloud' => '',
'lock' => '',
'exclamation' => '',
'devices' => '',
'desktop' => '',
'mobile' => '',
'scheduled' => '',
'plus' => '',
'duplicator' => '',
'robot' => '',
'aisparks' => '',
'logo-sr' => '',
'step-1' => '',
'step-2' => '',
'menu' => '',
)
);
}