Last active
September 24, 2015 07:12
-
-
Save soderlind/66ad6f977ab55a4977e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use Gravatar as your site icon, add the code to your (child) theme functions.php or use it in a plugin | |
* Requires: WordPress 4.3 | |
* | |
* @param array $meta_tags default site icon meta tags array | |
* @return array return the modified site icon meta tags array | |
*/ | |
function gravatar_site_icon ($meta_tags) { | |
$email = get_bloginfo('admin_email', 'raw'); // modify this if you want to use another email address, eg: $email = '[email protected]'; | |
$email_md5_hash = md5(strtolower(trim($email))); | |
$meta_tags = array( | |
sprintf( '<link rel="icon" href="%s" sizes="32x32" />', 'http://www.gravatar.com/avatar/' . $email_md5_hash . '?s=32;' ) ), | |
sprintf( '<link rel="icon" href="%s" sizes="192x192" />', 'http://www.gravatar.com/avatar/' . $email_md5_hash . '?s=192;' ) ), | |
sprintf( '<link rel="apple-touch-icon-precomposed" href="%s">', 'http://www.gravatar.com/avatar/' . $email_md5_hash . '?s=180;' ) ), | |
sprintf( '<meta name="msapplication-TileImage" content="%s">', 'http://www.gravatar.com/avatar/' . $email_md5_hash . '?s=270;' ) ), | |
); | |
return $meta_tags; | |
} | |
add_filters( 'site_icon_meta_tags', 'gravatar_site_icon' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment