=== Ordnerwerk – Medienordner für die Mediathek ===
Contributors: webdesigneckental
Tags: media library, folders, media organizer, gallery, slideshow
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.6.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Virtual folders for the WordPress media library, plus folder-based galleries, slideshows and a lightbox. Files are never moved or renamed.

== Description ==

Ordnerwerk ("folder works" in German) adds a folder tree with unlimited nesting to the WordPress media library. Folders are purely virtual: they are stored as a hierarchical taxonomy on attachments, so nothing on your server changes.

**What makes it different from other folder plugins**

* **Completely free, no limits.** Every feature is included. There is no premium version, no cap on the number of folders or files, and no upsell screens.
* **Folders become living galleries.** Any folder can be inserted as a gallery or slideshow that stays in sync with the folder: drop new photos into the folder and they appear on the page, no editing required.
* **Lightbox included.** Regular WordPress galleries get an accessible lightbox without a second plugin.
* **Nothing external.** No third-party libraries, no external services, no tracking.
* **Made for editors, not developers.** Built for a school website maintained by teachers, with a step-by-step guide inside WordPress.

**Your files stay exactly where they are**

* Files remain untouched in `/wp-content/uploads/`.
* File names never change.
* The URL of a media item never changes.
* Deleting a folder never deletes media. The items simply become "Unassigned".

**Organise the media library**

* Create, rename, move and delete folders and subfolders.
* Folder tree in the media library (grid and list view) and in the WordPress media modal (block editor and classic editor), combinable with search, media type and date filters.
* "All media" and "Unassigned" views with live counters.
* Assign media by drag and drop, including multiple selection; drop onto "Unassigned" to remove an assignment.
* Sort folders manually by drag and drop.
* Files uploaded while a folder is open are assigned to that folder automatically.

**Galleries and slideshows from a folder**

Turn any folder into a gallery (grid) or a slideshow with a few clicks. In the block editor use the blocks "Medienordner-Galerie" and "Slideshow aus Medienordner"; in the classic editor use the buttons next to "Add Media".

* Automatic synchronisation (default): new images in the folder appear on the page by themselves, removed images disappear. Alternatively static: exactly the images you chose. Editing the image list by hand in the classic editor makes the gallery static.
* Sort by upload date (oldest or newest first), title or file name.
* Slideshow: one large image on a fixed stage without layout shifts, arrows, position indicator, keyboard and swipe support. Optional automatic rotation every 3, 5, 7 or 10 seconds with a pause button; rotation pauses outside the viewport, in background tabs and when "reduce motion" is enabled.
* Clicking an image opens the lightbox with exactly the images of that gallery or slideshow.
* If the plugin is deactivated, WordPress shows a regular gallery with the last saved images in the same place. Nothing breaks.

**Lightbox for regular WordPress galleries**

Regular WordPress galleries stay regular WordPress galleries. Clicking a gallery image opens a lightbox with a large image, caption, counter, previous/next buttons, keyboard control (arrow keys, Escape, focus trap) and swipe gestures.

* Supports the Gutenberg gallery block (including the markup used before WordPress 5.9) and the classic `[gallery]` shortcode.
* Single images do not get a lightbox.
* The WordPress core lightbox ("Expand on click") takes precedence when it is enabled.
* Custom links set by the editor stay regular links. Only images without a link, or linked to the media file or attachment page, are handled.
* Galleries from other plugins (FooGallery, NextGEN and others) are left alone.
* Saved post content is never modified; everything happens on output only.
* CSS and JavaScript are only loaded on pages that actually contain a gallery.

To exclude a single gallery, add the CSS class `medienordner-ohne-lightbox` under "Advanced" in the editor. To disable the lightbox completely, add this to a small plugin of your own:

`add_filter( 'medienordner_lightbox_enabled', '__return_false' );`

**Built-in guide for editors**

A step-by-step guide is available under "Media" → "Medienordner-Anleitung" and via the "Anleitung" link in the plugin list.

**Language**

The user interface and the built-in guide are currently in German. All strings use the text domain `ordnerwerk`, so translations can be contributed on translate.wordpress.org.

**Privacy, security and dependencies**

No external services, no tracking, no CDN and no bundled third-party libraries. The plugin does not add links or branding to the public website. All REST and upload requests are protected by nonces and capability checks on the server.

**Copyright and license**

Copyright (C) 2026 Webdesign-Eckental.de. Ordnerwerk is free software, released under the GNU General Public License version 2 or later.

== Installation ==

1. Upload the `ordnerwerk` folder to `/wp-content/plugins/`, or install the plugin via "Plugins" → "Add New".
2. Activate the plugin.
3. Open "Media" → "Library". The folder tree appears on the left.

== Frequently Asked Questions ==

= Are my files moved or renamed? =

No. Folders are virtual (a hierarchical taxonomy on attachments). Files, file names and URLs never change.

= What happens when I delete a folder? =

The folder and its subfolders are removed. The media items inside are not deleted; they appear under "Unassigned".

= What happens when I deactivate or delete the plugin? =

Media and posts stay untouched. Galleries and slideshows created from a folder turn into regular WordPress galleries showing the last saved images. Folder assignments are kept in the database so that nothing is lost if you reactivate the plugin later.

= Can I use the folders when inserting media into a post? =

Yes. The folder tree is available in the WordPress media modal ("Add Media", "Create Gallery", "Add to Gallery" and the block editor media picker).

= Which editors are supported? =

Both the block editor and the classic editor.

= Does the plugin load anything from external servers? =

No. All scripts, styles and images ship with the plugin.

== Screenshots ==

1. The folder tree in the media library: create, nest and sort folders. Counters show how many items each folder contains.
2. The folder tree is also available in the media modal of the block editor and the classic editor.
3. The "Medienordner-Galerie" block and its settings: folder, layout, sorting and automatic synchronisation.
4. A gallery created from a folder, as visitors see it.
5. A slideshow created from a folder, with arrows and position indicator.
6. Clicking an image opens the built-in lightbox with the images of that gallery.
7. The built-in step-by-step guide for editors (in German).

== Changelog ==

= 0.6.1 =
* Added copyright notice (Webdesign-Eckental.de) to the plugin header and readme.
* Added screenshots to the plugin page. No functional changes.

= 0.6.0 =
* The plugin is now called "Ordnerwerk" (slug `ordnerwerk`, text domain `ordnerwerk`). Folders, assignments, galleries and all settings are unaffected: the taxonomy, block and REST names are unchanged.

= 0.5.5 =
* Preparation for the WordPress.org plugin directory: English readme, license file, cleaned-up plugin header.
* Security: the folder parameter sent with uploads now carries its own nonce in addition to the WordPress upload nonce.

= 0.5.4 =
* Fixed: In the classic editor, changes to the image list of a gallery or slideshow (removing, adding or reordering images via "Edit Gallery") had no effect because automatic synchronisation restored the folder content on save. A manually edited image list now makes the gallery static and shows exactly those images; an unchanged list keeps the synchronisation.
* Improved: The classic editor opens synchronised galleries with the current folder content instead of the state of the last save.
* The built-in guide describes editing in the classic editor accordingly.

= 0.5.3 =
* When uploading into an open folder, the tile with the progress bar now appears immediately. Previously the view stayed empty until the file had finished uploading.
* The short refresh of the view after an upload is gone: images are no longer reloaded from the server.

= 0.5.2 =
* Fixed: Folder names with special characters such as "&" or quotation marks were shown as "&amp;" in the folder tree, the media modal, the gallery block and the classic editor dialog.
* Fixed: A folder moved into another folder kept its old sort position and ended up at a random place; it is now placed at the end of the target level.
* Fixed: An incomplete "medienordner_capabilities" filter could trigger PHP warnings; missing capabilities now fall back to the defaults.
* Fixed: A manipulated folder parameter in array form was read as folder ID 1; it is now ignored.
* The guide describes the upload behaviour since 0.5.1 (uploads land in the open folder).

= 0.5.1 =
* Fixed: Files uploaded in the media library while a folder is open (drag and drop or "Add New") are now assigned to that folder instead of landing under "Unassigned".
* Counters and the folder view update after the upload without reloading the page.
* Under "All media" and "Unassigned", new uploads stay unassigned as before.

= 0.5.0 =
* New: "Gallery from folder". Images of a folder as an even grid, as the block "Medienordner-Galerie" in the block editor and via the button "Galerie aus Medienordner" in the classic editor.
* New: Automatic synchronisation of the gallery. New or removed images in the folder are picked up without editing the post again; optionally static with fixed images. Sorting by upload date, title or file name.
* New: "Slideshow from folder". One large image without layout shifts, arrows, position indicator, keyboard and swipe; automatic rotation every 3, 5, 7 or 10 seconds with a pause button, respecting "reduce motion" and pausing outside the viewport.
* New: Automatic synchronisation for the slideshow as well.
* New: Gallery and slideshow open the existing lightbox with exactly their own images.
* Improved: Preview in the classic editor. A compact grid with a label (folder, synchronisation); for the slideshow the first image with image count and interval.
* New: Built-in guide under "Media" → "Medienordner-Anleitung" and via the "Anleitung" link in the plugin list.
* When the plugin is deactivated, WordPress shows a regular gallery with the last saved images in the same place.
* Fixed: A link containing exactly one gallery image now opens the lightbox via keyboard (Enter) as well.

= 0.4.2 =
* Fixed: The folder sidebar no longer appears in the "Edit Gallery" dialog, where only the images already in the gallery are edited.
* Folders remain available in "Add Media", "Create Gallery", "Add to Gallery" and the block editor media picker.
* Added media modal state tests.

= 0.4.1 =
* Fixed: A layout glitch in the WordPress media modal where media tiles were partly hidden behind the folder column.
* Improved: Layout of the WordPress filters in the media modal at medium window widths.
* Added a regression test for the media modal at different window widths.

= 0.4.0 =
* New: Lightbox for WordPress galleries on the front end (Gutenberg and classic).
* Large image in its original size via wp_get_attachment_image_src(), also for classic galleries with thumbnails.
* Images without a link are reachable via keyboard (Enter/Space open the lightbox).
* Focus trap, focus return, Escape and arrow keys; scroll lock without page jump.
* Loading and error state, support for safe areas and mobile browser bars.
* The WordPress core lightbox takes precedence; custom links and third-party gallery plugins are left alone.
* Assets are only loaded on pages with a gallery, also in block themes.
* Fixed: Assigning via drag and drop failed with a server error under PHP 8 (REST route /zuordnung).

= 0.3.0 =
* The folder tree is now available in the WordPress media modal as well.
* Filtering in the media modal without reloading, combinable with search, media type and date.
* The current media selection is kept when switching folders.
* Works in the block editor and the classic editor.
* The folder area can be collapsed for narrow modals.

= 0.2.0 =
* Media can be assigned to a folder by drag and drop.
* Multiple selection is supported.
* "Unassigned" is a valid drop target.
* Folders can be sorted manually by drag and drop.
* New REST routes /zuordnung and /sortierung.

= 0.1.0 =
* First version (phase 1): folder management and filtering of the media library.
