wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php:17SVG ICONS CLASS Retrieve the SVG code for the specified icon. Based on a solution in Twenty Nineteen.
Every hook that fires from inside TwentyTwenty_SVG_Icons, in the order it appears in the class, grouped by the method that fires it.
$ui_iconsarraypublic static$social_icons_maparraypublic static$social_iconsarraypublic static class TwentyTwenty_SVG_Icons { /** * GET SVG CODE * Get the SVG code for the specified icon * * @since Twenty Twenty 1.0 * * @param string $icon Icon name. * @param string $group Icon group. * @param string $color Color. */ public static function get_svg( $icon, $group = 'ui', $color = '#1A1A1B' ) { if ( 'ui' === $group ) { $arr = self::$ui_icons; } elseif ( 'social' === $group ) { $arr = self::$social_icons; } else { $arr = array(); } /** * Filters Twenty Twenty'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 1.5 * * @param array $arr Array of icons. */ $arr = apply_filters( "twentytwenty_svg_icons_{$group}", $arr ); /** * Filters an SVG icon's color. * * @since Twenty Twenty 1.5 * * @param string $color The icon color. * @param string $icon The icon name. * @param string $group The icon group. */ $color = apply_filters( 'twentytwenty_svg_icon_color', $color, $icon, $group ); if ( array_key_exists( $icon, $arr ) ) { $repl = '<svg class="svg-icon" aria-hidden="true" role="img" focusable="false" '; $svg = preg_replace( '/^<svg /', $repl, trim( $arr[ $icon ] ) ); // Add extra attributes to SVG code. $svg = str_replace( '#1A1A1B', $color, $svg ); // Replace the color. $svg = str_replace( '#', '%23', $svg ); // Urlencode hashes. $svg = preg_replace( "/([\n\t]+)/", ' ', $svg ); // Remove newlines & tabs. $svg = preg_replace( '/>\s*</', '><', $svg ); // Remove whitespace between SVG tags. return $svg; } return null; } /** * GET SOCIAL LINK SVG * Detects the social network from a URL and returns the SVG code for its icon. * * @since Twenty Twenty 1.0 * * @param string $uri The URL to retrieve SVG for. */ public static function get_social_link_svg( $uri ) { static $regex_map; // Only compute regex map once, for performance. if ( ! isset( $regex_map ) ) { $regex_map = array(); /** * Filters Twenty Twenty's array of domain mappings for social icons. * * By default, each Icon ID is matched against a .com TLD. To override this behavior, * specify all the domains it covers (including the .com TLD too, if applicable). * * @since Twenty Twenty 1.5 * * @param array $social_icons_map Array of default social icons. */ $map = apply_filters( 'twentytwenty_social_icons_map', self::$social_icons_map );Introduced in Twenty Twenty 1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.