Skip to content

Instantly share code, notes, and snippets.

@charleslouis
Last active February 27, 2019 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charleslouis/5661830 to your computer and use it in GitHub Desktop.
Save charleslouis/5661830 to your computer and use it in GitHub Desktop.
PHP - Wordpress - embed favicon and touch icons
Créer les icones suivantes en respectant les noms et dimensions des images :
name = "favicon.png" - size="16x16"
name = "favicon.ico" - size="16x16"
<!-- For third-generation iPad with high-resolution Retina display: -->
name = "apple-touch-icon-144x144-precomposed.png" - size="144x144"
<!-- For iPhone with high-resolution Retina display: -->
name = "apple-touch-icon-114x114-precomposed.png" - size="114x114"
<!-- For first- and second-generation iPad: -->
name = "apple-touch-icon-72x72-precomposed.png" - size="72x72"
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
name = "apple-touch-icon.png" - size="72x72"
name = "apple-touch-icon-precomposed.png"
<?php
// icons.php
define('ICONS_FOLDER', get_stylesheet_directory_uri()."/_inc/img/icones"); // define Icon folder to be used in embed_touchIcons() in icons.php
function embed_touchIcons() {
// embed touch icons and facebook pics
echo '\n\t
<link rel="icon" type="image/png" sizes="16x16" href="'. ICONS_FOLDER .'/favicon.png">
<link rel="icon" type="image/ico" sizes="16x16" href="'. ICONS_FOLDER .'/favicon.ico">
<!-- For third-generation iPad with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="'. ICONS_FOLDER .'/apple-touch-icon-144x144-precomposed.png">
<!-- For iPhone with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="'. ICONS_FOLDER .'/apple-touch-icon-114x114-precomposed.png">
<!-- For first- and second-generation iPad: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="'. ICONS_FOLDER .'/apple-touch-icon-72x72-precomposed.png">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon" sizes="72x72" href="'. ICONS_FOLDER .'/apple-touch-icon.png">
<link rel="apple-touch-icon-precomposed" href="'. ICONS_FOLDER .'/apple-touch-icon-precomposed.png">
<!-- For Facebook and co. -->
<link rel="image_src" href="'. ICONS_FOLDER .'/apple-touch-icon-144x144-precomposed.png">
<link rel="image_src" href="'. ICONS_FOLDER .'/logo-sante-ensemble-red.png">
<meta property="og:image" content="'. ICONS_FOLDER .'/apple-touch-icon-144x144-precomposed.png" />
<meta property="og:image" content="'. ICONS_FOLDER .'/logo-sante-ensemble-red.png" />\n';
}
add_action('myBp_head', 'embed_touchIcons');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment