\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 = Maizzy_SVG_Icons::$social_icons_map; // Use reference instead of copy, to save memory.
foreach (array_keys(Maizzy_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 maizzy_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',
),
'google-plus' => array(
'plus.google.com',
),
'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',
),
);
/* --------------------------------------------------------------------
ICON STORAGE
Store the code for all SVGs in an array
-------------------------------------------------------------------- */
static $icons = array(
'link' => '',
'arrow-down' => '',
'arrow-up' => '',
'arrow-left' => '',
'arrow-right' => '',
'arrow-down-circled' => '',
'bookmark' => '',
'calendar' => '',
'clock' => '',
'calendar-full' => '',
'chevron-down' => '',
'comment' => '',
'cross' => '',
'edit' => '',
'folder' => '',
'search' => '',
'tag' => '',
'user' => '',
'menu' => '',
'close' => '',
'moon' => '',
'sun' => '',
'play' => '',
'pause' => '',
'mute' => '',
'unmute' => '',
'amazon' => '',
'apple' => '',
'bandcamp' => '',
'behance' => '',
'chain' => '',
'codepen' => '',
'deviantart' => '',
'digg' => '',
'dribbble' => '',
'dropbox' => '',
'etsy' => '',
'facebook' => '',
'feed' => '',
'flickr' => '',
'foursquare' => '',
'goodreads' => '',
'google-plus' => '',
'google' => '',
'github' => '',
'instagram' => '',
'lastfm' => '',
'linkedin' => '',
'mail' => '',
'meetup' => '',
'medium' => '',
'pinterest' => '',
'pocket' => '',
'reddit' => '',
'skype' => '',
'slideshare' => '',
'snapchat' => '',
'soundcloud' => '',
'spotify' => '',
'stumbleupon' => '',
'tumblr' => '',
'twitch' => '',
'twitter' => '',
'vimeo' => '',
'vk' => '',
'WordPress' => '',
'yelp' => '',
'youtube' => '',
'whatsapp' => '',
'popular' => '',
'flash' => '',
'comment-2' => '',
);
}
endif;