%4$s', $width, $height, $viewbox, $icons[ $name ], $name ); } /** * 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. * * @return void */ function wsrw_icon( $name, $width = 20, $height = 20, $viewbox = '' ) { $icon = wsrw_get_icon( $name, $width, $height, $viewbox ); if ( ! empty( $icon ) ) { echo wp_kses( $icon, wsrw_get_icon_allowed_tags() ); } } /** * Get the allowed tags for svg icons, to be used in wp_kses. * * @return array * @see wsrw_icon() * @see wp_kses() */ function wsrw_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, ), 'g' => array( 'fill' => true, 'clip-path' => true, 'transform' => true, 'stroke' => true, ), 'title' => array( 'title' => true ), 'path' => array( 'd' => true, 'fill' => true, 'fill-rule' => true, 'clip-rule' => 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 wsrw_icons() { return (array) apply_filters( 'wsrw_icons', array( 'logo' => '', 'logo-text' => '', 'close' => '', 'upload' => '', 'help' => '', 'facebook' => '', 'twitter' => '', 'lock' => '', 'arrow-right' => '', 'arrow-left' => '', 'd-arrow-right' => '', 'd-arrow-left' => '', ) ); } /** * Returns the site domain. * * @return string */ function wsrw_get_site_domain() { return wp_parse_url( home_url(), PHP_URL_HOST ); }