Fix blank plugin icons in the Plugins window#209
Merged
Conversation
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
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.
Closes #201
Problem
In the Installed tab of the native Plugins window, only ~6 of 34 plugin
rows showed an icon — the rest rendered a blank grey square (the empty
container before the dashicon fallback painted, or the dashicon
itself).
Root cause
desktop_mode_plugins_window_field_icon_urlderived the wp.org iconURL from
$row['textdomain']:But the wp.org asset directory at
ps.w.org/<slug>/assets/is keyed onthe plugin's folder name (the .org repo slug), not its text
domain. These coincide only by accident:
woocommerce/woocommerce.phphas text domainwoo→ 404wordpress-seo/wp-seo.phphas text domainyoast-seo→ 404Text Domain:header at all →null→ no icon attemptedA secondary issue: the URL always pointed at
icon.svg, but manywp.org plugins ship only
icon-128x128.png/icon-256x256.png. Evenwhen the slug was right, an SVG-only URL would 404 for those plugins.
There was no race condition, no transient, no fetch error — just a
wrong slug source plus a single-format URL.
Fix
PHP —
includes/plugins-window/rest-fields.phpResolve the slug from
dirname( $plugin_file )(the folder name).Fall back to
textdomainfor single-file plugins likehello.phpwhere the folder is
..JS — new helper
src/plugins-window/icon-fallback.tsattachIconFallback( img, url, onExhausted )wires an<img>to walka candidate chain on load failure:
Only applied when the URL matches the
ps.w.org/<slug>/assets/shape — custom URLs (set via the
desktop_mode_plugins_window_icon_urlfilter) are still one-shot. Wired into both consumers:
src/plugins-window/installed-view.ts(table icon)src/plugins-window/installed-detail.ts(expanded-row hero icon)Also corrected
deriveSlug()ininstalled-detail.ts, which fed thewp.org detail panel (
fetchPluginInfo, reviews tab, etc.) and had thesame textdomain-first bug.
Tests
Updated
tests/phpunit/tests/pluginsWindowRegistration.phpto coverthe new behaviour:
akismet).woocommercevswoo).Verification
npm run build— cleannpm run lint— clean./node_modules/.bin/tsc --noEmit— cleannpm run test:js— 137 files / 1208 tests pass--filter='PluginsWindowRegistration'— 29 tests / 54 assertions pass (incl. 5 icon-url cases)Files changed
includes/plugins-window/rest-fields.phpsrc/plugins-window/icon-fallback.ts(new)src/plugins-window/installed-view.tssrc/plugins-window/installed-detail.tstests/phpunit/tests/pluginsWindowRegistration.phpassets/js/desktop[.min].js(build output)