You appear to be a bot. Output may be restricted
Description
GET SOCIAL LINK SVG Detects the social network from a URL and returns the SVG code for its icon.
Usage
TwentyTwenty_SVG_Icons::get_social_link_svg( $uri );
Parameters
- $uri
- ( string ) required – The URL to retrieve SVG for.
Returns
void
Source
File name: twentytwenty/classes/class-twentytwenty-svg-icons.php
Lines:
1 to 40 of 40
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 ); /** * Filters Twenty Twenty's array of social icons. * * @since Twenty Twenty 1.5 * * @param array $social_icons Array of default social icons. */ $social_icons = apply_filters( 'twentytwenty_svg_icons_social', self::$social_icons ); foreach ( array_keys( $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 twentytwenty_get_theme_svg( $icon, 'social' ); } } return null; }