Skip to content

Instantly share code, notes, and snippets.

@mattradford
Last active June 20, 2019 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattradford/b9796d1419b3df910fd963e6052a8b6a to your computer and use it in GitHub Desktop.
Save mattradford/b9796d1419b3df910fd963e6052a8b6a to your computer and use it in GitHub Desktop.
Output Yoast Social links
/**
* Return a nav element populated with Yoast social accounts
*/
function yoast_social_accounts()
{
if ($social_accounts = get_option('wpseo_social')) {
$fb_url = $social_accounts['facebook_site'];
$twitter_account = $social_accounts['twitter_site'];
$youtube_url = $social_accounts['youtube_url'];
if (isset($fb_url) || isset($twitter_url) || isset($youtube_url) ) {
$social_output = '<nav class="social__accounts"><ul>';
isset($fb_url) ? $social_output .= '<li><a href="'. esc_url($fb_url) .'" target="_blank" class="facebook"><span class="screen-reader-text">Facebook</span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 38 34"><path fill="currentColor" d="M21 6c-2.761 0-5 2.239-5 5v3h-4v4h4v14h4v-14h4.5l1-4h-5.5v-3c0-0.552 0.448-1 1-1h5v-4h-5z"></path></svg></a></li>' : '';
isset($twitter_account) ? $social_output .= '<li><a href="https://www.twitter.com/'. esc_html($twitter_account) .'" target="_blank" class="twitter"><span class="screen-reader-text">Twitter</span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<path fill="currentColor" d="M32 6.076c-1.177 0.522-2.443 0.875-3.771 1.034 1.355-0.813 2.396-2.099 2.887-3.632-1.269 0.752-2.674 1.299-4.169 1.593-1.198-1.276-2.904-2.073-4.792-2.073-3.626 0-6.565 2.939-6.565 6.565 0 0.515 0.058 1.016 0.17 1.496-5.456-0.274-10.294-2.888-13.532-6.86-0.565 0.97-0.889 2.097-0.889 3.301 0 2.278 1.159 4.287 2.921 5.465-1.076-0.034-2.088-0.329-2.974-0.821-0.001 0.027-0.001 0.055-0.001 0.083 0 3.181 2.263 5.834 5.266 6.437-0.551 0.15-1.131 0.23-1.73 0.23-0.423 0-0.834-0.041-1.235-0.118 0.835 2.608 3.26 4.506 6.133 4.559-2.247 1.761-5.078 2.81-8.154 2.81-0.53 0-1.052-0.031-1.566-0.092 2.905 1.863 6.356 2.95 10.064 2.95 12.076 0 18.679-10.004 18.679-18.68 0-0.285-0.006-0.568-0.019-0.849 1.283-0.926 2.396-2.082 3.276-3.398z"></path></svg></a></li>' : '';
isset($youtube_url) ? $social_output .= '<li><a href="'. esc_url($youtube_url) .'" target="_blank" class="youtube"><span class="screen-reader-text" class="youtube">YouTube</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="12px" viewBox="0 0 24 18"><path fill-rule="evenodd" fill="currentColor" d="M23.758,4.333 C23.758,4.333 23.524,2.699 22.804,1.980 C21.891,1.036 20.868,1.032 20.400,0.976 C17.042,0.736 12.004,0.736 12.004,0.736 L11.994,0.736 C11.994,0.736 6.957,0.736 3.599,0.976 C3.130,1.032 2.107,1.036 1.194,1.980 C0.475,2.699 0.241,4.333 0.241,4.333 C0.241,4.333 0.001,6.251 0.001,8.169 L0.001,9.967 C0.001,11.884 0.241,13.802 0.241,13.802 C0.241,13.802 0.475,15.436 1.194,16.155 C2.107,17.099 3.306,17.070 3.841,17.168 C5.760,17.350 12.000,17.406 12.000,17.406 C12.000,17.406 17.042,17.399 20.400,17.159 C20.868,17.104 21.891,17.099 22.804,16.155 C23.524,15.436 23.758,13.802 23.758,13.802 C23.758,13.802 23.998,11.884 23.998,9.967 L23.998,8.169 C23.998,6.251 23.758,4.333 23.758,4.333 ZM9.522,12.146 L9.521,5.486 L16.005,8.828 L9.522,12.146 Z"></path></svg></a></li>' : '';
$social_output .= '</nav>';
return $social_output;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment