create-icon-set-for-generat.../functions.php

23 lines
775 B
PHP
Raw Permalink Normal View History

2024-04-11 07:30:53 +02:00
<?php
2024-04-11 07:33:27 +02:00
//directory where icons arent
2024-04-11 07:30:53 +02:00
$files = scandir(get_stylesheet_directory().'/icons2');
2024-04-11 07:33:27 +02:00
2024-04-11 07:30:53 +02:00
function store_svg_icons_to_json($files) {
2024-04-11 07:33:27 +02:00
// init empty array
2024-04-11 07:30:53 +02:00
$json_svgs=[];
2024-04-11 07:33:27 +02:00
// loop into files list
2024-04-11 07:30:53 +02:00
foreach($files as $file) {
2024-04-11 07:33:27 +02:00
// remove empty files
2024-04-11 07:30:53 +02:00
if($file!='.' && $file!='..'){
$name = str_replace('.svg','',$file);
$icon = esc_html(file_get_contents(get_stylesheet_directory().'/icons2/'.$file));
$icon = str_replace('http://www.w3.org/2000/svg">','',$icon);
$jsons_svgs[] = [
'name'=>$name,
'icon'=>str_replace('http://www.w3.org/2000/svg">','',$icon)
];
}
}
return $jsons_svgs;
2024-04-11 07:33:27 +02:00
}