Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active December 14, 2015 21:34
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 glueckpress/e70f2e28b12d29d49301 to your computer and use it in GitHub Desktop.
Save glueckpress/e70f2e28b12d29d49301 to your computer and use it in GitHub Desktop.
[WordPress] Mini plugin, adds favicons, touch icons and tiles for desktop browsers, iOS, Android and Windows. Generated HTML output via http://realfavicongenerator.net/. Requires a sub-directory /img to store all images in. HEADS UP: This is no longer needed as of WordPress 4.3!
<?php
/**
* Plugin Name: Real Favicons
* Description: Adds favicons, touch icons and tiles for desktop browsers, iOS, Android and Windows. Generate HTML output via <a href="http://realfavicongenerator.net/">realfavicongenerator.net</a>. Store all generated images in sub-directory /img.
* Version: 2014.01
* Author: Caspar Hübinger
* Author URI: http://glueckpress.com/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Load plugin.
*/
function real_favicons() {
add_action( 'wp_head', 'real_favicons_add_favicons' );
}
add_action( 'plugins_loaded', 'real_favicons' );
/**
* Add the favicon.
*
* @return string
*/
function real_favicons_add_favicons() {
$img_url = plugin_dir_url( __FILE__ ) . "img";
?>
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo $img_url; ?>/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo $img_url; ?>/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo $img_url; ?>/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo $img_url; ?>/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo $img_url; ?>/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo $img_url; ?>/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo $img_url; ?>/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo $img_url; ?>/apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-32x32.png" sizes="32x32">
<meta name="msapplication-TileColor" content="#0095bc">
<meta name="msapplication-TileImage" content="<?php echo $img_url; ?>/mstile-144x144.png">
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment