Created
March 10, 2017 16:06
-
-
Save imliam/444775c3cebd92deb01d8e537d02c026 to your computer and use it in GitHub Desktop.
PHP - Font Awesome Icon Helper
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 | |
/* | |
|-------------------------------------------------------------------------- | |
| PHP - Font Awesome Icon Helper | |
|-------------------------------------------------------------------------- | |
| | |
| A helper function to build the HTML for a Font Awesome icon with all of | |
| the recommended accessibility tags. | |
| | |
*/ | |
if (! function_exists('fa')) { | |
function fa(string $icon, string $title=null, string $class='') { | |
$response = '<span class="fa fa-'.$icon.' '.$class.'" aria-hidden="true"'. (!empty($title) ? 'title="'.$title.'"' : '').'></span>'; | |
if (!empty($title)) { | |
$response .= '<span class="sr-only">'.$title.'</span>'; | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment