Skip to content

Commit dd07254

Browse files
committed
fix(Icon): skip registering collections with no SVG files
Register icon collections only after glob finds at least one SVG so empty dist/images folders do not appear in the block picker.
1 parent d72f966 commit dd07254

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎inc/Services/Icon.php‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ private function register_collection( string $collection_slug, array $collection
9696
return;
9797
}
9898

99-
wp_register_icon_collection(
100-
$collection_slug,
101-
[
102-
'label' => $collection_args['label'] ?? $collection_slug,
103-
'description' => $collection_args['description'] ?? '',
104-
]
105-
);
106-
10799
$icons_directory = $this->resolve_icons_directory( $source_subdir );
108100

109101
if ( null === $icons_directory ) {
@@ -112,6 +104,18 @@ private function register_collection( string $collection_slug, array $collection
112104

113105
$svg_files = $this->get_collection_svg_files( $icons_directory );
114106

107+
if ( [] === $svg_files ) {
108+
return;
109+
}
110+
111+
wp_register_icon_collection(
112+
$collection_slug,
113+
[
114+
'label' => $collection_args['label'] ?? $collection_slug,
115+
'description' => $collection_args['description'] ?? '',
116+
]
117+
);
118+
115119
foreach ( $svg_files as $svg_file ) {
116120
$this->register_icon_file( $collection_slug, $svg_file );
117121
}

0 commit comments

Comments
 (0)