Skip to content

Instantly share code, notes, and snippets.

@Ataurr
Created August 8, 2019 07:53
Show Gist options
  • Save Ataurr/29b740cd7e520939ab0e2c89c3dd6ec3 to your computer and use it in GitHub Desktop.
Save Ataurr/29b740cd7e520939ab0e2c89c3dd6ec3 to your computer and use it in GitHub Desktop.
if (!function_exists('xs_convert_fa4_to_fa5')) {
/**
* Convert a Font Awesome 4 icon to Font Awesome 5
*
* @param $icon
*
* @return string
*/
function xs_convert_fa4_to_fa5($icon)
{
$icon = explode(' ', $icon);
$icon = (isset($icon[1])) ? $icon[1] : $icon[0];
if ($icon === 'fa-tachometer' || $icon === 'fa-dashboard') {
$icon = 'fa-tachometer-alt';
}
else if ($icon === 'fa-chain') {
$icon = 'fa-link';
}
else if ($icon === 'fa-cloud-download') {
$icon = 'fa-cloud-download-alt';
}
else if ($icon === 'fa-thumbs-o-up') {
$icon = 'fa-thumbs-up';
}
else if ($icon === 'fa-thumbs-o-down') {
$icon = 'fa-thumbs-down';
}
else if ($icon === 'fa-sort-amount-asc') {
$icon = 'fa-sort-amount-down';
}
else if ($icon === 'fa-bar-chart') {
$icon = 'fa-chart-bar';
}
else if ($icon === 'fa-thumb-tack') {
$icon = 'fa-thumbtack';
}
else if ($icon === 'fa-group') {
$icon = 'fa-users';
}
else if ($icon === 'fa-commenting-o') {
$icon = 'fa-comment-dots';
}
else if ($icon === 'fa-sign-out') {
$icon = 'fa-sign-out-alt';
}
else if ($icon === 'fa-cutlery') {
$icon = 'fa-utensils';
}
else if ($icon === 'fa-diamond') {
$icon = 'fa-gem';
}
else if ($icon === 'fa-refresh') {
$icon = 'fa-sync';
}
else if ($icon === 'fa-facebook-official') {
$icon = 'fa-facebook';
}
else if (substr($icon, -2) === '-o') {
$icon = str_replace('-o', '', $icon);
}
$prefix = (in_array($icon, [
'fa-500px',
'fa-adn',
'fa-amazon',
'fa-android',
'fa-angellist',
'fa-apple',
'fa-behance',
'fa-behance-square',
'fa-bitbucket',
'fa-bitbucket-square',
'fa-black-tie',
'fa-buysellads',
'fa-chrome',
'fa-codepen',
'fa-codiepie',
'fa-connectdevelop',
'fa-contao',
'fa-css3',
'fa-dashcube',
'fa-delicious',
'fa-deviantart',
'fa-digg',
'fa-dribbble',
'fa-dropbox',
'fa-drupal',
'fa-edge',
'fa-empire',
'fa-envira',
'fa-expeditedssl',
'fa-fa',
'fa-facebook',
'fa-facebook-f',
'fa-facebook-official',
'fa-facebook-square',
'fa-firefox',
'fa-first-order',
'fa-flickr',
'fa-font-awesome',
'fa-fonticons',
'fa-fort-awesome',
'fa-forumbee',
'fa-foursquare',
'fa-ge',
'fa-get-pocket',
'fa-git',
'fa-git-square',
'fa-github',
'fa-github-alt',
'fa-github-square',
'fa-gitlab',
'fa-gittip',
'fa-glide',
'fa-glide-g',
'fa-google',
'fa-google-plus',
'fa-google-plus-circle',
'fa-google-plus-official',
'fa-google-plus-square',
'fa-gratipay',
'fa-hacker-news',
'fa-houzz',
'fa-html5',
'fa-instagram',
'fa-internet-explorer',
'fa-ioxhost',
'fa-joomla',
'fa-jsfiddle',
'fa-lastfm',
'fa-lastfm-square',
'fa-leanpub',
'fa-linkedin',
'fa-linkedin-square',
'fa-linux',
'fa-maxcdn',
'fa-meanpath',
'fa-medium',
'fa-mixcloud',
'fa-modx',
'fa-odnoklassniki',
'fa-odnoklassniki-square',
'fa-opencart',
'fa-openid',
'fa-opera',
'fa-optin-monster',
'fa-pagelines',
'fa-pied-piper',
'fa-pied-piper-alt',
'fa-pied-piper-pp',
'fa-pinterest',
'fa-pinterest-p',
'fa-pinterest-square',
'fa-product-hunt',
'fa-qq',
'fa-ra',
'fa-rebel',
'fa-reddit',
'fa-reddit-alien',
'fa-reddit-square',
'fa-renren',
'fa-resistance',
'fa-safari',
'fa-scribd',
'fa-sellsy',
'fa-shirtsinbulk',
'fa-simplybuilt',
'fa-skyatlas',
'fa-skype',
'fa-slack',
'fa-slideshare',
'fa-snapchat',
'fa-snapchat-ghost',
'fa-snapchat-square',
'fa-soundcloud',
'fa-spotify',
'fa-stack-exchange',
'fa-stack-overflow',
'fa-steam',
'fa-steam-square',
'fa-stumbleupon',
'fa-stumbleupon-circle',
'fa-tencent-weibo',
'fa-themeisle',
'fa-trello',
'fa-tripadvisor',
'fa-tumblr',
'fa-tumblr-square',
'fa-twitch',
'fa-twitter',
'fa-twitter-square',
'fa-usb',
'fa-viacoin',
'fa-viadeo',
'fa-viadeo-square',
'fa-vimeo',
'fa-vimeo-square',
'fa-vine',
'fa-vk',
'fa-wechat',
'fa-weibo',
'fa-weixin',
'fa-whatsapp',
'fa-wikipedia-w',
'fa-windows',
'fa-wordpress',
'fa-wpbeginner',
'fa-wpforms',
'fa-xing',
'fa-xing-square',
'fa-y-combinator',
'fa-y-combinator-square',
'fa-yahoo',
'fa-yc',
'fa-yc-square',
'fa-yelp',
'fa-yoast',
'fa-youtube',
'fa-youtube-square',
])) ? 'fab' : 'fas';
return $prefix .' '. $icon;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment