You appear to be a bot. Output may be restricted
Description
Gets the SVG code for a given icon.
Usage
$string = Twenty_Twenty_One_SVG_Icons::get_svg( $group, $icon, $size );
Parameters
- $group
- ( string ) required – The icon group.
- $icon
- ( string ) required – The icon.
- $size
- ( int ) required – The icon-size in pixels.
Returns
string
Source
File name: twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php
Lines:
1 to 32 of 32
public static function get_svg( $group, $icon, $size ) { if ( 'ui' === $group ) { $arr = self::$icons; } elseif ( 'social' === $group ) { $arr = self::$social_icons; } else { $arr = array(); } /** * Filters Twenty Twenty-Ones's array of icons. * * The dynamic portion of the hook name, `$group`, refers to * the name of the group of icons, either "ui" or "social". * * @since Twenty Twenty-One 1.0 * * @param array $arr Array of icons. */ $arr = apply_filters( "twenty_twenty_one_svg_icons_{$group}", $arr ); $svg = ''; if ( array_key_exists( $icon, $arr ) ) { $repl = sprintf( '<svg class="svg-icon" width="%d" height="%d" aria-hidden="true" role="img" focusable="false" ', $size, $size ); $svg = preg_replace( '/^<svg /', $repl, trim( $arr[ $icon ] ) ); // Add extra attributes to SVG code. } // @phpstan-ignore-next-line. return $svg; }