Skip to content

Instantly share code, notes, and snippets.

@llemurya
Created January 17, 2017 11:03
Show Gist options
  • Save llemurya/41a35e31c093a56fc4a1b552606b7aae to your computer and use it in GitHub Desktop.
Save llemurya/41a35e31c093a56fc4a1b552606b7aae to your computer and use it in GitHub Desktop.
parse dashicons and group by categories.
(function(){
var children = jQuery('#iconlist').children();
console.log(children);
var category = '';
var collector = [];
children.each(function(){
if (jQuery(this).is('h4')) {
console.log('is h4');
category = jQuery(this).text().toLowerCase().replace(' ', '-');
console.log(category);
} else {
var obj = {};
obj['category'] =[];
obj.category.push(category);
obj['icon'] = jQuery(this).attr('class').replace('dashicons dashicons-', '');
collector.push(obj);
}
});
return JSON.stringify(collector);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment