You appear to be a bot. Output may be restricted
Description
Detects the social network from a URL and returns the SVG code for its icon.
Usage
TwentyNineteen_SVG_Icons::get_social_link_svg( $uri, $size );
Parameters
- $uri
- ( mixed ) required –
- $size
- ( mixed ) required –
Returns
void
Source
File name: twentynineteen/classes/class-twentynineteen-svg-icons.php
Lines:
1 to 19 of 19
public static function get_social_link_svg( $uri, $size ) { static $regex_map; // Only compute regex map once, for performance. if ( ! isset( $regex_map ) ) { $regex_map = array(); $map = &self::$social_icons_map; // Use reference instead of copy, to save memory. foreach ( array_keys( self::$social_icons ) as $icon ) { $domains = array_key_exists( $icon, $map ) ? $map[ $icon ] : array( sprintf( '%s.com', $icon ) ); $domains = array_map( 'trim', $domains ); // Remove leading/trailing spaces, to prevent regex from failing to match. $domains = array_map( 'preg_quote', $domains ); $regex_map[ $icon ] = sprintf( '/(%s)/i', implode( '|', $domains ) ); } } foreach ( $regex_map as $icon => $regex ) { if ( preg_match( $regex, $uri ) ) { return self::get_svg( 'social', $icon, $size ); } } return null; }