function jetpack_social_svgenericons_menu($items) { if (current_theme_supports('jetpack-svgenericons')) { foreach ($items as $item) { $subject = $item->url; $feed_pattern = '/\\/feed\\/?/i'; $mail_pattern = '/mailto/i'; $skype_pattern = '/skype/i'; $domain_pattern = '/([a-z]*)(\\.com|\\.org|\\.io|\\.tv|\\.co)/i'; $domains = array('codepen', 'digg', 'dribbble', 'dropbox', 'facebook', 'flickr', 'foursquare', 'github', 'plus.google', 'instagram', 'linkedin', 'path', 'pinterest', 'getpocket', 'polldaddy', 'reddit', 'spotify', 'stumbleupon', 'tumblr', 'twitch', 'twitter', 'vimeo', 'vine', 'wordpress', 'youtube'); // Match feed URLs if (preg_match($feed_pattern, $subject, $matches)) { $icon = get_jetpack_svgenericon('feed'); // Match a mailto link } elseif (preg_match($mail_pattern, $subject, $matches)) { $icon = get_jetpack_svgenericon('mail'); // Match a Skype link } elseif (preg_match($skype_pattern, $subject, $matches)) { $icon = get_jetpack_svgenericon('skype'); // Match various domains } elseif (preg_match($domain_pattern, $subject, $matches) && in_array($matches[1], $domains)) { $icon = get_jetpack_svgenericon($matches[1]); // Fall back to our default share icon } else { $icon = get_jetpack_svgenericon('share'); } $item->title = $icon . '<span class="screen-reader-text">' . $item->title . '</span>'; } } return $items; }
function jetpack_svgenericon($name) { echo get_jetpack_svgenericon($name); }