Skip to content

Commit 479331e

Browse files
committed
perf(Icon): rely on core for SVG file path resolution
Pass glob paths directly to wp_register_icon instead of realpath and is_readable on every init; directory safety stays in resolve_icons_directory().
1 parent b92149a commit 479331e

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

‎inc/Services/Icon.php‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,7 @@ private function resolve_icons_directory( string $source_subdir ): ?string {
158158
* @return void
159159
*/
160160
private function register_icon_file( string $collection_slug, string $svg_file ): void {
161-
$real_file = realpath( $svg_file );
162-
163-
if ( false === $real_file || ! is_readable( $real_file ) ) {
164-
return;
165-
}
166-
167-
$icon_slug = pathinfo( $real_file, PATHINFO_FILENAME );
161+
$icon_slug = pathinfo( $svg_file, PATHINFO_FILENAME );
168162
$icon_slug = sanitize_title( (string) $icon_slug );
169163

170164
if ( '' === $icon_slug ) {
@@ -183,7 +177,7 @@ private function register_icon_file( string $collection_slug, string $svg_file )
183177
'bff_icon_properties',
184178
[
185179
'label' => $label,
186-
'file_path' => $real_file,
180+
'file_path' => $svg_file,
187181
],
188182
$icon_name,
189183
$collection_slug

0 commit comments

Comments
 (0)