Repository navigation
(perf): Register icon collections - #527
Open
firestar300 wants to merge 7 commits into
Open
firestar300 wants to merge 7 commits into
firestar300 wants to merge 7 commits into
Conversation
Skip registering init callbacks when icon registry functions are unavailable instead of repeating function_exists checks in each handler.
Align slug normalization with WP_Icons_Registry so underscores and mixed-case filenames are preserved instead of stripped or silently merged.
Pass glob paths directly to wp_register_icon instead of realpath and is_readable on every init; directory safety stays in resolve_icons_directory().
Avoid glob on every request by storing file paths in a transient keyed by directory mtime; bypass the cache when WP_DEBUG is enabled.
Register icon collections only after glob finds at least one SVG so empty dist/images folders do not appear in the block picker.
Rahe
reviewed
Nov 4, 2026
Rahe
reviewed
Nov 4, 2026
Rahe
requested changes
Nov 4, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Correctifs pour #525 .
Note
Low Risk
Changes are confined to theme icon registration and caching; the main caveat is stale transient lists if icons change without updating the collection directory mtime, mitigated in theme development mode.
Overview
Icon registration is gated earlier and avoids repeated filesystem work on each request.
The WordPress icon APIs are now checked once in
boot()before anyinithooks are attached, and the duplicate guards inside collection/icon registration are removed. Collection registration is reordered so a collection is only registered after SVG files are found, with empty glob results handled via new helpers instead of silent early returns mid-loop.SVG file lists are cached in transients (one week, keyed by directory path and directory
mtime), with cache bypassed when development mode isthemeorall. Per-icon registration dropsrealpath/is_readablechecks and usessanitize_title()for slugs while passing through the resolved path from directory resolution.Reviewed by Cursor Bugbot for commit bb513f4. Bugbot is set up for automated code reviews on this repo. Configure here.