1583 posts How's the surf doing?
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 3 years
  • Had an item featured on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
tommusrhodus says
https://github.com/tommusrhodus/FontAwesome-4.1.0-Class-Names

Thought this might help a few people. There’s likely duplicates in there so feel free to submit a change :)

269 posts
  • Has been part of the Envato Community for over 2 years
  • Has sold $40,000+ on Envato Market
  • Sells items exclusively on Envato Market
subsolar says

Oh great, thanks for sharing, this will sure come in handy!

Bookmarked!

DistinctiveThemes
DistinctiveThemes Recent Posts Threads Started
257 posts
  • Sells items exclusively on Envato Market
  • Has sold $10,000+ on Envato Market
  • Has been part of the Envato Community for over 1 year
  • Contributed a blog post
+3 more
DistinctiveThemes says

Awesome! Thanks for sharing Tom

1468 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 6 years
  • Has sold $250,000+ on Envato Market
+5 more
fuelthemes says

This will come in handy :)

1285 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
+5 more
Smartik says
Isn’t it better to update the class name with a single click and save them in DB or a static file?
/**
 * Font Awesome
 *
 * @param string $path font awesomwe css file path
 * @return array
 */
function fontAwesome($path){

    $css = file_get_contents($path);
    $pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"(.+)";\s+}/';

    preg_match_all($pattern, $css, $matches, PREG_SET_ORDER);

    $icons = array();
    foreach ($matches as $match) {
        $icons[$match[1]] = $match[2];
    }
    return $icons;

}

// Usage 
// -------------------------------------------------------
$icons = fontAwesome(PATH_TO_CSS . '/font-awesome/css/font-awesome.css');

// this will return an array with the following structure:
// -------------------------------------------------------
array(
...
[fa-glass] => \f000
...
);

// to replace the value with the name class:
// -------------------------------------------------------
$list_i = array();
foreach ($font as $key => $value) {
    $list_i[$key] = $key;
}
//Use it
print_r($list_i);

//To display the name class without prefix and dashes and Uppercase:
// -------------------------------------------------------

//Replace this:
$list_i[$key] = $key;

//with this
$list_i[$key] = ucfirst( str_ireplace(array('fa-', '-'), array('', ' '), $key) );

1583 posts How's the surf doing?
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 3 years
  • Had an item featured on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
tommusrhodus says

@Smartik, honest question, why would that method be better? Not challenging at all, just looking for your insight mate :)

In my case, I pull the list of icons into my theme options and my page builder, so once an icon is chosen it’s saved into an option, or into meta. So the array is only called in certain admin situations anyway and then the value saved by itself.

1285 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
+5 more
Smartik says

@Smartik, honest question, why would that method be better? Not challenging at all, just looking for your insight mate :) In my case, I pull the list of icons into my theme options and my page builder, so once an icon is chosen it’s saved into an option, or into meta. So the array is only called in certain admin situations anyway and then the value saved by itself.

Because you don’t have to update that list manually with every update of font awesome. In my example this will run everytime, but you can change it a bit and run it only when you want to update the list or write the array in a static file, or anything else.

It probably is not better, it is more flexible(that’s what I should say), and allow to manipulate the code in many ways. Your code is excelent for what it is intended to do, but I’ve just added another solution that allows to get the code in an easy way. :)

1583 posts How's the surf doing?
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 3 years
  • Had an item featured on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
tommusrhodus says

Because you don’t have to update that list manually with every update of font awesome.

Exactly what I wanted to hear, makes total sense now :)

Cheers mate, that’s an awesome snippet you’ve got there, thanks so much for sharing!

3 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
CodeSymbol says

Thanks for sharing.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by