1171 posts How's the surf doing?
  • Forum Superstar
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Referred between 200 and 499 users
  • Exclusive Author
  • Has been a member for 3-4 years
+2 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 :)

167 posts
  • Europe
  • Exclusive Author
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
subsolar says

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

Bookmarked!

DistinctiveThemes
DistinctiveThemes Recent Posts Threads Started
126 posts
  • United Kingdom
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 1-2 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
DistinctiveThemes says

Awesome! Thanks for sharing Tom

1315 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

This will come in handy :)

1068 posts
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 3-4 years
  • Exclusive Author
+1 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) );

1171 posts How's the surf doing?
  • Forum Superstar
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Referred between 200 and 499 users
  • Exclusive Author
  • Has been a member for 3-4 years
+2 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.

1068 posts
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 3-4 years
  • Exclusive Author
+1 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. :)

1171 posts How's the surf doing?
  • Forum Superstar
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Referred between 200 and 499 users
  • Exclusive Author
  • Has been a member for 3-4 years
+2 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
  • Sold between 1 000 and 5 000 dollars
  • Referred between 1 and 9 users
  • Bought between 1 and 9 items
  • Has been a member for 0-1 years
  • Exclusive Author
CodeSymbol says

Thanks for sharing.

by
by
by
by
by
by