Custom WordPress plugin that replaces the default flat media library with a structured folder view. Features: hierarchical folders via custom taxonomy, sidebar folder tree, drag & drop, modal integration with Elementor/builders, bulk assign, upload auto-assign, toast notifications. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4.4 KiB
4.4 KiB
phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, patterns-established, duration, started, completed
| phase | plan | subsystem | tags | requires | provides | affects | tech-stack | key-files | key-decisions | patterns-established | duration | started | completed | |||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 02-media-library-grid | 01 | media |
|
|
|
|
|
|
|
|
~10min | 2026-03-28 | 2026-03-28 |
Phase 2 Plan 01: Media Library Grid Integration Summary
Media grid filtering by folder click + drag & drop media assignment with live counter updates, integrated via WP backbone props and HTML5 Drag & Drop API.
Performance
| Metric | Value |
|---|---|
| Duration | ~10min |
| Tasks | 2 completed |
| Files created | 2 |
| Files modified | 4 |
Acceptance Criteria Results
| Criterion | Status | Notes |
|---|---|---|
| AC-1: Filtrowanie mediow po kliknieciu folderu | Pass | ajax_query_attachments_args + library.props.set |
| AC-2: Przypisywanie mediow przez AJAX | Pass | mfp_assign_media with folder_counts response |
| AC-3: Drag & drop mediow na foldery | Pass | HTML5 D&D + MutationObserver + counter refresh |
Accomplishments
- Server-side filter via
ajax_query_attachments_argshook — supports folder filtering and "uncategorized" (id=-1) mfp_assign_mediaendpoint assigns media to exactly 1 folder (or removes) and returns updated folder counts- HTML5 drag & drop from media grid thumbnails to folder tree with visual feedback
- Drop on "All Media" removes folder assignment
- MutationObserver catches dynamically loaded attachments for draggable setup
Files Created/Modified
| File | Change | Purpose |
|---|---|---|
includes/class-media-query.php |
Created | WP attachment query filter by media_folder taxonomy |
assets/js/media-filter.js |
Created | Grid filter via wp.media props + drag & drop logic |
includes/class-ajax-handler.php |
Modified | Added mfp_assign_media endpoint |
assets/js/folder-tree.js |
Modified | Exposed window.mfpRefreshTree() |
assets/css/admin.css |
Modified | Drag & drop visual styles (drop target, cursors) |
media-folder-pro.php |
Modified | MFP_Media_Query init, media-filter.js enqueue, i18n strings |
Decisions Made
| Decision | Rationale | Impact |
|---|---|---|
| Use ajax_query_attachments_args | Native WP filter, no core mods | Clean integration |
| library.props.set for grid reload | Backbone native, triggers AJAX automatically | No manual DOM manipulation |
| MutationObserver for infinite scroll | Attachments load dynamically, need draggable on each | Robust for any load pattern |
Deviations from Plan
None — plan executed exactly as written.
Issues Encountered
None
Next Phase Readiness
Ready:
- Full folder filtering + assignment pipeline operational
- media-filter.js pattern reusable for modal integration (Phase 3)
- mfp_assign_media endpoint ready for bulk use (Phase 4)
Concerns:
- Media modal uses different wp.media frame — will need separate integration path
- List view (table) not yet handled (deferred to Phase 4)
Blockers:
- None
Phase: 02-media-library-grid, Plan: 01 Completed: 2026-03-28