\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. * * @param string $uri The URL to retrieve SVG for. * @since Blogmarks 1.0 * */ 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 Blogmarks'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). * * @param array $social_icons_map Array of default social icons. * @since Blogmarks 1.0 * */ $map = apply_filters('blogmarks_social_icons_map', self::$social_icons_map); /** * Filters Blogmarks's array of social icons. * * @param array $social_icons Array of default social icons. * @since Blogmarks 1.0 * */ $social_icons = apply_filters('blogmarks_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 blogmarks_get_theme_svg($icon, 'social'); } } return null; } /** * ICON STORAGE * Store the code for all SVGs in an array. * * @since Blogmarks 1.0 * @var array */ public static $ui_icons = array( 'arrow-bar-right' => '', 'arrow-bar-up' => '', 'arrow-down' => '', 'arrow-down-circled' => '', 'arrow-left' => '', 'arrow-repeat' => '', 'arrow-right' => '', 'arrow-right-circle' => '', 'arrow-right-circle-fill' => '', 'arrow-right-short' => '', 'arrow-up' => '', 'arrow-up-circle' => '', 'arrow-up-circle-fill' => '', 'arrow-up-short' => '', 'bookmark' => '', 'calendar' => '', 'caret-right' => '', 'caret-right-fill' => '', 'caret-up' => '', 'caret-up-fill' => '', 'cart' => '', 'chat' => '', 'chevron-bar-up' => '', 'chevron-double-left' => ' ', 'chevron-double-right' => ' ', 'chevron-double-up' => '', 'chevron-down' => ' ', 'chevron-left' => '', 'chevron-right' => '', 'chevron-up' => ' ', 'clock-fill' => '', 'comment' => ' ', 'cross' => '', 'edit' => ' ', 'ellipsis' => '', 'envelope-fill' => '', 'folder' => '', 'folder2' => '', 'geo' => '', 'geo-alt-fill' => '', 'globe2' => '', 'home' => '', 'hot' => '', 'info-circle' => '', 'info-circle-fill' => '', 'latest' => '', 'link' => '', 'login' => '', 'menu' => '', 'modal-close' => '', 'my-account' => '', 'people-fill' => '', 'person' => '', 'person-circle' => '', 'phone' => '', 'popular' => '', 'printer-fill' => '', 'read' => '', 'search' => '', 'shuffle' => '', 'tag' => '', 'trending-graph' => '', 'time' => '', 'user' => '', 'image' => '', 'audio' => '', 'gallery' => '', 'quote' => '', 'video' => '', 'link' => '', ); /** * Social Icons – domain mappings. * * 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 Blogmarks 1.0 * @var array */ public 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', ), 'behance' => array( 'behance.net', ), 'codepen' => array( 'codepen.io', ), 'facebook' => array( 'facebook.com', 'fb.me', ), 'feed' => array( 'feed', ), 'google' => array( 'g.page', ), 'lastfm' => array( 'last.fm', ), 'mail' => array( 'mailto:', ), 'mastodon' => array( 'mastodon.social', 'pawoo.net', 'mstdn.jp', 'mastodon.cloud', 'mastodon.online', 'counter.social', 'mstdn.social', 'mas.to', 'mastodon.world', 'gc2.jp', ), 'pocket' => array( 'getpocket.com', ), 'telegram' => array( 't.me', 'telegram.org', 'telegram.com', ), 'threads' => array( 'threads.net', ), 'tiktok' => array( 'tiktok.com', ), 'twitch' => array( 'twitch.tv', ), 'twitter' => array( 'x.com', 'twitter.com', ), 'whatsapp' => array( 'wa.me', 'whatsapp.com', ), 'wordpress' => array( 'wordpress.com', 'wordpress.org', ), ); /** * Social Icons – svg sources. * * @since Blogmarks 1.0 * @var array */ public static $social_icons = array( '500px' => '', 'amazon' => ' ', 'bandcamp' => '', 'behance' => ' ', 'codepen' => '', 'deviantart' => '', 'dribbble' => ' ', 'dropbox' => ' ', 'etsy' => '', 'facebook' => ' ', 'feed' => ' ', 'flickr' => '', 'foursquare' => '', 'goodreads' => '', 'google' => ' ', 'github' => ' ', 'instagram' => ' ', 'lastfm' => '', 'line' => ' ', 'linkedin' => ' ', 'mail' => ' ', 'mastodon' => ' ', 'medium' => ' ', 'meetup' => '', 'odnoklassniki' => '', 'pinterest' => ' ', 'pocket' => '', 'reddit' => ' ', 'skype' => ' ', 'snapchat' => ' ', 'soundcloud' => '', 'spotify' => ' ', 'telegram' => ' ', 'threads' => ' ', 'tumblr' => '', 'tiktok' => ' ', 'twitch' => ' ', 'twitter' => ' ', 'viber' => '', 'vimeo' => ' ', 'vk' => '', 'whatsapp' => ' ', // phpcs:disable WordPress.WP.CapitalPDangit.Misspelled 'wordpress' => ' ', 'yelp' => ' ', 'youtube' => ' ', ); } }