=== R2 Media Folders ===
Contributors: rise2studio
Tags: media library, folders, media folders, media categories, attachments
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Organize the WordPress Media Library into nestable folders. A lightweight, dependency-free alternative to FileBird.

== Description ==

R2 Media Folders adds a folder tree to your Media Library so you can organize thousands of files into nestable folders.

* Folder tree sidebar in both grid and list views, with All Files and Unsorted virtual folders and live counts.
* Create, rename, delete and nest folders.
* Drag files (single or multi-select) into folders; bulk move supported.
* Drag folders to reorder and re-nest, with a saved manual order — or move them without dragging via Move to….
* Undo for every file and folder move.
* Folder menu (the "…" button or a right click): new subfolder, rename, move to, sort, delete. Delete explains what happens before anything is removed.
* Keyboard and screen-reader friendly folder tree.
* Croatian translation; folder names sort the way your admin language sorts them, and search ignores accents.
* Filter the library by folder — live in the grid, by URL in the list view.
* Full folder panel inside every media modal (classic editor "Add Media", ACF fields, Featured Image, block editor picker): folder tree with counts, search, and inline New Folder creation, plus a synced toolbar dropdown. Uploads made inside the modal land in the selected folder.
* Optional per-user private folders.
* One-click FileBird importer (idempotent) — migrate folders and file assignments, then deactivate FileBird.
* Settings: per-user folders, default order, and opt-in delete-on-uninstall.

Folders are stored as a native WordPress taxonomy, so they survive exports and are removed cleanly on uninstall. Your files are never deleted by this plugin.

== Installation ==

1. Upload the `r2-media-folders` folder to `/wp-content/plugins/`.
2. Activate the plugin through the Plugins screen.
3. Open Media → Library and use the folder tree on the left. Configure options under Settings → Media Folders.

== Frequently Asked Questions ==

= Does it move or delete my files? =
No. It only organizes files into folders (a taxonomy assignment). Your media files are never moved on disk or deleted.

= What happens if I delete a folder? =
The files inside it move to Unsorted and any subfolders move up one level. Nothing is lost.

= Is this related to FileBird? =
No. It is an original, independent plugin built by RISE2 Studio. FileBird was only used as a feature reference.

= How do I move folders precisely? =
Drag a folder onto the empty space with the dashed border: it shows exactly where the folder will go. The space goes above a folder when the pointer is on the upper half of its row and below it on the lower half. Closed folders never open by themselves while you drag.

To put a folder inside another one (open or closed), move the pointer to the "Into folder" area at the right of that row; the row turns green. To make a subfolder a top-level folder, drop it on "Move to the top level", which appears at the top of the panel while you drag. The label next to the panel always names the destination. Press Escape or release outside the panel to cancel.

You can also move a folder without dragging: open its menu (the "…" button, a right click, or Shift+F10) and choose Move to…, then pick the destination from a searchable list.

= Can I undo a move? =
Yes. After moving files or a folder, the confirmation message has an Undo button: files go back to the folders they came from, and a folder goes back to its old parent and position.

= How is the folder order kept? =
Folders follow the default order from Settings (name, newest or oldest first). When you drag a folder between others, that group of folders keeps its own manual order. To go back to the default, choose "Sort subfolders" in the parent folder's menu, or "Sort top-level folders" in the panel menu. While folder search is active, folders can only be moved into other folders; clear the search to reorder.

= Can I use it with the keyboard? =
Yes. The folder tree takes one Tab stop. Arrow keys move between folders (Right/Left open and close them), Enter opens a folder, F2 renames, Delete deletes, and Shift+F10 opens the folder menu.

New Folder in the toolbar creates a top-level folder. Use a folder's plus to create a subfolder; the inline editor shows its destination path.

== Changelog ==

= 1.5.0 =
* Undo after moving files or folders (in the message that confirms the move).
* Folder menu (the "…" button, right click, or Shift+F10): New subfolder, Rename, Move to…, Sort subfolders, Delete. Panel menu: New folder, Expand all, Collapse all, Sort top-level folders, Settings.
* Move to…: a searchable list of destinations — move a folder without dragging (keyboard, touch screens, long trees).
* Delete asks in a dialog that says how many files go to Unsorted and where the subfolders go.
* Dragging: the slot goes above or below a row by which half of the row the pointer is on; "Into folder" shows only on the row under the pointer and is about three times larger; the top-level target appears only while dragging, without moving the tree; the drag label sits beside the panel instead of over the rows; All Files is no longer offered as a drop target for files.
* A moved, created or renamed folder is briefly highlighted and scrolled into view.
* Croatian translation. Folder names sort the way the admin's language sorts them (Č, Ć, Š, Ž in place; "Folder 2" before "Folder 10"), and folder search ignores accents ("sibenik" finds "Šibenik") and highlights the match.
* Keyboard: arrow keys, Home/End, F2, Delete; one tab stop for the whole tree; messages are announced to screen readers.
* Fixed: on WordPress 7.0 the folder rows would break apart under the admin's own tree styles; the panel no longer depends on them.

= 1.4.1 =
* Fixed: the dashed insertion space and drag reordering now work with every default sorting setting, including Name (A–Z). No settings change is required.
* Fixed: reordered sibling groups retain their manual order after refresh; untouched branches keep their default order.
* Reorder validates sibling batches and reports persistence failures.

= 1.4.0 =
* Fixed: dragging no longer opens closed branches. Escape, invalid drops, background refreshes and save failures are handled explicitly.
* Improved: classic drag ordering with a real empty dashed insertion space, separate Inside targets for deliberate nesting, a top-level target, retained expansion/search/scroll state, and destination paths when creating subfolders.

= 1.3.2 =
* Changed: asset cache-busting is now automatic — script/style URLs carry the plugin version plus each file's modification time, so browsers can never keep serving a stale copy of the folder JS/CSS after an update (previously that could show wrong folder-filter values until a hard refresh).

= 1.3.1 =
* Fixed: uploading into a selected folder inside the media modal updated the count but the file didn't appear in the grid until a page refresh — filtered wp.media collections don't receive finished uploads, so the view now re-queries when an upload batch completes (verified live).
* Fixed: deleting an attachment from the modal left the folder counts stale until refresh — the tree now refreshes when an attachment is destroyed.
* Fixed: the folder filter in the modal toolbar was mis-placed and label-less, pushing the toolbar into a scrollbar. It now ships the same label-above-select shape as the core type/date filters, explicitly placed in the toolbar grid.

= 1.3.0 =
* Added: FileBird-style folder panel inside the media modal — folder tree with counts, expand/collapse, live search and inline New Folder creation, shown in a left column in every wp.media modal (classic editor, ACF image/gallery fields, Featured Image, block editor picker). Selecting a folder filters the grid; the toolbar dropdown stays as a synced fallback; uploads inside the modal land in the selected folder. On desktop the panel joins core's classic left menu column (select frames like ACF/Featured Image get the column un-hidden at core's own metrics); on mobile it lives inside core's dropdown menu with its own scrolling.

= 1.2.3 =
* Fixed: the folder sidebar didn't appear on a bare /wp-admin/upload.php (it showed only with an explicit ?mode=grid or ?mode=list in the URL). The plugin assumed grid whenever ?mode= was absent, but WordPress renders the user's saved view preference there; the mode is now resolved exactly like core does it.

= 1.2.2 =
* Fixed: in the Media Library **list view**, the whole file table rendered *below* the folder sidebar instead of beside it (grid view was fine). WordPress core styles `.tablenav { clear: both }`, which was clearing our floated sidebar; the list anchor now establishes its own block formatting context so the clear no longer applies to it.

= 1.2.1 =
* Fixed: in the media modal (e.g. picking a Featured Image) the folder filter wrapped onto a second row and slipped into the scrollable attachments area. Widened the toolbar's secondary grid so the type, date and folder filters stay inline. CSS-only, scoped so no other media toolbar is affected.

= 1.2.0 =
* Added: self-hosted update support — a "Check for updates" link on the Plugins page and integration with Dashboard → Updates, served from plugins.rise2.studio.
* Added: a "Settings" shortcut link on the Plugins page row.
* Changed: renamed the admin menu item under Settings from "Media Folders" to "R2 Media Folders".

= 1.1.1 =
* Fixed: search box magnifier icon no longer overlaps the placeholder text.
* Changed: made the folder taxonomy explicitly non-public (publicly_queryable=false) and added belt-and-suspenders sitemap exclusions (WP core + Yoast). It was already excluded from sitemaps/SEO plugins; this guarantees it stays that way.

= 1.1.0 =
* Added: inline create/rename in the tree (folder field + Cancel/Save, Enter/Esc) instead of a browser prompt.
* Added: folder search box that live-filters the tree by name.
* Added: a first-activation prompt offering to import FileBird folders when FileBird is detected.

= 1.0.4 =
* Security: turned off REST exposure for the media_folder taxonomy (it was enumerable, incl. anonymously, via /wp/v2/media-folder). Hardened reorder() to enforce manage capability and visibility-gated the ?r2mf_folder= filter. All from a pre-production security review.

= 1.0.3 =
* Changed: per-file upload progress (FileBird-style floating panel) — each file shows its own progress bar and status, with a header count, instead of one overall indicator.

= 1.0.2 =
* Added: upload progress indicator, and uploaded files now appear in the current folder immediately (the grid re-queries on upload completion) — no page refresh needed.

= 1.0.1 =
* Fixed: clicking a folder did nothing after opening and closing an image in the grid (wp.media left the grid stuck on the closed attachment view). The sidebar no longer re-parents the media frame, and folder filtering now recovers reliably.
* Fixed: uploading while inside a folder now puts the file in that folder (and shows the normal upload progress), instead of landing in All Files.

= 1.0.0 =
* Initial release: folder tree, nesting, drag-and-drop file moves, bulk move, drag-to-reorder/nest, library + media-modal filtering, per-user folders, settings, clean uninstall.
