@@ -174,13 +174,14 @@ public function get_svg($id, $opts=[]) {
174
174
public function get_icon_details ($ id ) {
175
175
$ icon = array ();
176
176
177
- $ id = explode (' ' , $ id );
178
- $ dir = $ this ->get_icon_dir ($ id );
179
- $ filename = $ this ->get_icon_filename (end ($ id ));
177
+ $ classes = explode (' ' , $ id );
178
+ $ dir = $ this ->get_icon_dir ($ classes );
179
+ $ filename = $ this ->get_icon_filename ($ classes , $ dir );
180
+ $ filepath = $ this ->get_icon_filepath ($ dir , $ filename );
180
181
181
182
$ icon ['dir ' ] = $ dir ;
182
183
$ icon ['filename ' ] = $ filename ;
183
- $ icon ['filepath ' ] = str_replace ( ' / ' , DIRECTORY_SEPARATOR , " $ this -> svg_dir / $ dir / $ filename .svg " ) ;
184
+ $ icon ['filepath ' ] = $ filepath ;
184
185
185
186
if (!is_file ($ icon ['filepath ' ])) {
186
187
throw new Exception ('File ' . $ icon ['filepath ' ] . ' does not exist. ' );
@@ -233,10 +234,36 @@ public function get_icon_dir($classes) {
233
234
/**
234
235
* Get the icon's SVG file name
235
236
*
236
- * @param string $icon_name
237
+ * @param array $classes
238
+ * @param string $dir
237
239
* @return string
238
240
*/
239
- public function get_icon_filename ($ icon_name ) {
240
- return str_replace ('fa- ' , '' , $ icon_name );
241
+ public function get_icon_filename ($ classes , $ dir ) {
242
+ foreach ($ classes as $ class ) {
243
+ $ filename = str_replace ('fa- ' , '' , $ class );
244
+ $ path = $ this ->get_icon_filepath ($ dir , $ filename );
245
+
246
+ if (is_file ($ path )) {
247
+ return $ filename ;
248
+ }
249
+ }
250
+
251
+ $ id = join (' ' , $ classes );
252
+
253
+ throw new Exception ("No icon found for ' $ id' " );
254
+ }
255
+
256
+
257
+
258
+
259
+ /**
260
+ * Get the icon's SVG file path
261
+ *
262
+ * @param string $dir
263
+ * @param string $filename
264
+ * @return string
265
+ */
266
+ public function get_icon_filepath ($ dir , $ filename ) {
267
+ return str_replace ('/ ' , DIRECTORY_SEPARATOR , "$ this ->svg_dir / $ dir/ $ filename.svg " );
241
268
}
242
269
}
0 commit comments