Created
November 21, 2013 01:41
-
-
Save ahansson89/7574653 to your computer and use it in GitHub Desktop.
Add a Font Awesome icons select to CPT meta by humanmade: https://github.com/humanmade/Custom-Meta-Boxes/
This file contains hidden or 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
class ah_is_awesome { | |
function __construct() { | |
if(! class_exists( 'CMB_Meta_Box' ) ) { | |
require_once( 'includes/custom-meta/custom-meta-boxes.php' ); | |
} | |
} | |
function font_awesome_array() { | |
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"(.+)";\s+}/'; | |
$subject = file_get_contents(plugin_dir_url( __FILE__ ) . 'css/style.css'); | |
preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER); | |
$icons = array(); | |
asort($icons); | |
foreach($matches as $match){ | |
$icons[$match[1]] = $match[1]; | |
} | |
return $icons; | |
} | |
function custom_meta( array $meta_boxes ) { | |
$meta_boxes[] = array( | |
'title' => 'Meta Options', | |
'pages' => 'ah_resume_skill', //Your custom post type | |
'fields' => array( | |
array( | |
'id' => 'icon', | |
'name' => __( 'Select icon', 'audio-player' ), | |
'type' => 'select', | |
'cols' => 6, | |
'options' => $this->font_awesome_array() | |
), | |
), | |
); | |
return $meta_boxes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment