\s*<', $svg); // Remove white space between SVG tags. return $svg; } return null; } static function get_theme_svg_name($url) { static $regex_map; // Only compute regex map once, for performance. if (!isset($regex_map)) { $regex_map = array(); $map = Advance_Blog_SVG_Icons::$social_icons_map; // Use reference instead of copy, to save memory. foreach (array_keys(Advance_Blog_SVG_Icons::$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, $url)) { return advance_blog_get_theme_svg($icon);; } } return null; } static $social_icons_map = array( 'amazon' => array( 'amazon.com', 'amazon.cn', 'amazon.in', 'amazon.fr', 'amazon.de', 'amazon.it', 'amazon.nl', 'amazon.es', 'amazon.co', 'amazon.ca', ), 'apple' => array( 'apple.com', 'itunes.com', ), 'behance' => array( 'behance.net', ), 'codepen' => array( 'codepen.io', ), 'facebook' => array( 'facebook.com', 'fb.me', ), 'feed' => array( 'feed', ), 'lastfm' => array( 'last.fm', ), 'mail' => array( 'mailto:', ), 'slideshare' => array( 'slideshare.net', ), 'pocket' => array( 'getpocket.com', ), 'twitch' => array( 'twitch.tv', ), 'wordpress' => array( 'wordpress.com', 'wordpress.org', ), 'telegram' => array( 'telegram.org', 't.me', ), ); /* -------------------------------------------------------------------- ICON STORAGE Store the code for all SVGs in an array -------------------------------------------------------------------- */ static $icons = array( 'audio' => '', 'gallery' => '', 'image' => '', 'video' => '', 'arrow-down' => '', 'arrow-left' => '', 'arrow-right' => '', 'arrow-up' => '', 'chevron-down' => '', 'chevron-up' => '', 'search' => '', 'amazon' => '', 'apple' => '', 'bandcamp' => '', 'behance' => '', 'chain' => '', 'codepen' => '', 'deviantart' => '', 'digg' => '', 'dribbble' => '', 'dropbox' => '', 'etsy' => '', 'facebook' => '', 'feed' => '', 'flickr' => '', 'foursquare' => '', 'goodreads' => '', 'github' => '', 'instagram' => '', 'lastfm' => '', 'linkedin' => '', 'mail' => '', 'meetup' => '', 'medium' => '', 'pinterest' => '', 'pocket' => '', 'reddit' => '', 'skype' => '', 'slideshare' => '', 'snapchat' => '', 'soundcloud' => '', 'spotify' => '', 'stumbleupon' => '', 'tumblr' => '', 'twitch' => '', 'twitter' => '', 'vimeo' => '', 'vk' => '', 'wordpress' => '', 'telegram' => '', 'yelp' => '', 'youtube' => '', 'tiktok' => '', 'whatsapp' => '', ); } endif;