Last active
November 5, 2018 09:04
-
-
Save Balachandark/048d40f8eb18a9a9c7623dc949ff8d1a to your computer and use it in GitHub Desktop.
Remove all unwanted data from the fontawesome json file
This file contains 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
/** | |
* 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