Skip to content

Instantly share code, notes, and snippets.

@Balachandark
Last active November 5, 2018 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Balachandark/048d40f8eb18a9a9c7623dc949ff8d1a to your computer and use it in GitHub Desktop.
Save Balachandark/048d40f8eb18a9a9c7623dc949ff8d1a to your computer and use it in GitHub Desktop.
Remove all unwanted data from the fontawesome json file
/**
* Remove unwanted values from font awesome json object
*
* @since 1.0.0
* @param array $json Decoded fontawesome json file data.
*/
public static function remove_unwanted_data( $json ) {
// Remove unwanted code from the json file
foreach ($json as $index => $value) {
/* Remove all unwanted data from the fontawesome json file */
// Remove Changes, Ligature, Unicode from the array
unset( $value['changes'], $value['ligatures'], $value['unicode'] );
// Remove last modifiled from the svg array
if ( isset( $value['svg']['brands'] ) ) {
unset( $value['svg']['brands']['last_modified'], $value['svg']['brands']['raw'], $value['svg']['brands']['width'], $value['svg']['brands']['height'] );
} else if ( isset( $value['svg']['solid'] ) ) {
unset( $value['svg']['solid']['last_modified'], $value['svg']['solid']['raw'], $value['svg']['solid']['width'], $value['svg']['solid']['height'] );
}
$json[$index] = $value;
}
$json = json_encode( $json, JSON_PRETTY_PRINT );
file_put_contents( ASTRA_WIDGETS_DIR . 'assets/fonts/icons.json', $json);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment