Refactor My WordPress to use <wpd-tile> + add post status ribbons#233
Conversation
- Updated the fetchEntityList and fetchEntityDetail functions to include the post status in the API responses. - Enhanced EntityListItem and EntityDetail interfaces to support the new status field. - Introduced a new setting to toggle the visibility of post status ribbons in the user interface. - Implemented a checkbox in the settings to allow users to enable or disable the display of post status ribbons. - Created a new WpdTile component to represent tiles in the My WordPress interface, including status ribbons for non-published posts. - Added tests for the new WpdTile component and its behavior regarding status ribbons and drag-and-drop functionality.
<wpd-tile> + add post status ribbons
|
@claude can you review this pr please? |
|
Claude finished @AllTerrainDeveloper's task in 2m 21s —— View job PR Review: Refactor My WordPress to use
|
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
Summary
Consolidates every tile renderer in the shell behind a single canonical
<wpd-tile>web component, lifts the desktop-files tile builder onto ageneric
TileSpecadapter, and surfaces unpublished post status(
Draft/Pending/Private/Scheduled) as a diagonal cornerribbon on My WordPress tiles. Also lands a server-side
post→attachment resolver so the Media drill-in view catches references
that the previous client-side regex missed.
What changed
New
<wpd-tile>component (src/ui/components/wpd-tile/)The canonical tile element used everywhere a tile shows up — desktop
wallpaper, folder windows, every My WordPress section (Posts, Pages,
Users, Media, drill-in usage), and any plugin surface that wants the
same chrome. Light-DOM by design so existing modifier classes
(
__media-tile,__tile--user,__tile--usage) keep working fromexternal CSS. The host element IS the tile —
data-placement-id,style.left/top, anddocument.querySelector('.desktop-mode-file-tile')all keep pointing at the same node.
The component owns icon-vs-thumbnail rendering, the status ribbon
(
<wpd-ribbon>placement, gated by the per-usershowPostStatusRibbonsOS setting), the lock badge for access-gateditems, drag-out wiring, and keyboard activation (Enter / Space).
Generic
TileSpecrenderer (src/desktop-files/tile-spec.ts)buildTileFromSpec(spec)instantiates a<wpd-tile>and reflects specfields onto attributes.
attachTileDragOut(tile, payload)factors outthe standard pointerdown → DragManager dance so no builder duplicates
it any more.
file-tile.tsis now a thin placement → spec adapter on top ofbuildTileFromSpec, plus the desktop-files-specific behavior(double-click →
openFile, access-gated toast, share-folder badgehook). The placement-shaped
desktop-mode.files.tile-*plugin hooksurface is preserved unchanged.
My WordPress migrated to
<wpd-tile>index.ts,media-list.ts,media-detail.tsall drop their bespokebuildXxxTile()DOM construction in favor ofbuildTileFromSpec+attachTileDragOut. Net effect: same DOM contract, one tile renderer,free status-ribbon + drag-out plumbing.
Post status ribbons
showPostStatusRibbons(default ON) with acheckbox in OS Settings → Features.
fetchEntityList/fetchEntityDetailcarry poststatusin theREST response;
EntityListItem/EntityDetailgained the field.publishposts surface a diagonal corner ribbon in the tile(tone varies by status: draft=warning, pending=info, private=danger,
scheduled=primary). Rendered via the existing
<wpd-ribbon>component — no hand-rolled corner CSS.
Server-side attached-media resolver
New
includes/my-wordpress/attached-media.phpregistersdesktop_mode_attached_mediaon every public post type. Resolvesattachment ids from the post in four passes — featured image +
wp-image-Nblock class +[caption id="attachment_N"]shortcodes +data-id/data-attachment-idattributes + raw<img src>URLs viaattachment_url_to_postid()(with in-request caching and-scaled.jpg↔ original URL variants).Filterable via
desktop_mode_my_wordpress_attached_mediaso ACF /page-builder / post-meta gallery plugins can append their own refs.
media-usage.phpalso gains the same-scaledvariant handling sothe reverse lookup ("which posts use this attachment?") catches the
same cases.
Hook surface
desktop-mode.files.tile-class,desktop-mode.files.tile-element,desktop-mode.files.tile-rendered,desktop-mode.files.grid-rendered.desktop-mode.tile.class+desktop-mode.tile.rendered— fire on every<wpd-tile>paintanywhere in the shell, so plugins can decorate tiles across all
surfaces, not just desktop files.
desktop_mode_my_wordpress_attached_mediaPHP filter +
desktop_mode_attached_mediaREST field on all publicpost types.
Docs
docs/files-on-desktop.md— documents the new genericdesktop-mode.tile.*pair alongside the preserved placement-shapedfilters; calls out stability for each.
docs/hooks-reference.md— full entry fordesktop_mode_my_wordpress_attached_mediawith REST field shapeand sanitization notes.
Test plan
npm run lint./node_modules/.bin/tsc --noEmitnpm run test:js(150 files / 1366 tests)npm run build(deterministic — no bundle diffs after rebuild)php -lon every changed PHP fileshowPostStatusRibbonsin OS Settings → Features,confirm ribbons appear/disappear on My WordPress Posts grid
verify it lands as a shortcut placement
<img src>(nowp-image-Nclass) — verify it shows in"Used in"
verify tile selection, drag-rearrange, share-folder badge,
access-gated lock all still work
desktop-mode.files.tile-classor
desktop-mode.files.tile-elementstill receives the filter