Media folder

Choose or create a real physical upload subfolder (not a virtual one) from the classic Add Media screen.


Information

Author:

ROBOTSTXT

Download

Price:

€0.00
Log in to download

A free ROBOTSTXT account is required. Log in, then install the Manager (by ROBOTSTXT) plugin on your site and connect it with your API key to install this plugin and receive updates — at no cost.


Requirements

Version:

1.0.2

WordPress:

4.4

7.1

PHP >=

8.0

Changelog

1.0.2

Release date: 2026-09-12

Fixed

  • Fatal error on sites where another plugin calls wp_upload_dir() during plugin loading (e.g. widget-context, whose constructor does): that fires the upload routing before WordPress loads the pluggable functions, so the capability check crashed. The routing now bails until wp_get_current_user() exists; real upload requests re-fire it after full bootstrap.

Compatibility

  • WordPress: 4.4 – 7.1
  • PHP: 8.0 – 8.5

1.0.1

Release date: 2026-09-12

Fixed

  • Folder picker script: a syntax error (a stray brace introduced during the 1.0.0 security cleanup) prevented the script from executing in the browser — no path preview under the folder picker and uploads ignored the chosen folder.

Changed

  • The pre-deploy verification script now validates JavaScript syntax before any release.

Compatibility

  • WordPress: 4.4 – 7.1
  • PHP: 8.0 – 8.5

1.0.0

Release date: 2026-09-12

Highlights

  • First stable release: choose or create a real upload subfolder from the classic Media screens.

Added

  • Folder picker (“Organize media in folders”) on the classic Add Media screen (media-new.php): existing-folder select, new-folder input, and a live path preview — visible in both the drag & drop and the browser uploader modes.
  • Folder picker inside the Media Library’s (upload.php) Add-media drag & drop frame.
  • Upload routing through the upload_dir filter for all three classic upload transports (Plupload dropzone, browser-uploader form, async attachment handler), appended to the path WordPress computed so year/month organization is respected either way; thumbnails land in the same subfolder.
  • Folder-name sanitization: rejects traversal (..), separators, null bytes, and unusable names; truncates to 96 bytes.
  • Known-folder index (robotstxt_mediafolder_known_folders, autoload off): folders used by an upload are remembered for the picker, sanitized before store and deduplicated.
  • Uninstall deletes only the folder index option; uploaded files and attachments are never touched.
  • Security: the routing additionally requires an admin context with the upload_files capability; all PHP files guarded against direct access.
  • Translations: Spanish (es_ES) and Catalan (ca) shipped.

Compatibility

  • WordPress: 4.4 – 7.1
  • PHP: 8.0 – 8.5
  • Multisite: declares Network: true but has not yet been tested on a Multisite install; scheduled for a follow-up release.

Tests

  • 74 PHPUnit tests (headers, sanitizer, index, filter behaviors, picker screen; line coverage 92.68%).
  • PHPCS (WordPress-Core/Docs/Extra), PHPStan level 9, PHPCompatibility 8.0-8.5, pre-deploy clean-context AI audit.

0.1.0

Release date: 2026-09-08

Highlights

  • Initial development scaffold.

Added

  • Plugin bootstrap: header, constants, PSR-4-style autoloader (RobotstxtMediafolder namespace), text domain registration.
  • Activation (no-op) and uninstall wiring: uninstall deletes only the folder index option, never uploaded files or attachment records.
  • Core upload routing: uploads from the classic Add Media screen (action=upload-attachment) land in the chosen subfolder, appended to the path WordPress computed (year/month honored either way).
  • Folder-name sanitization: rejects traversal (..), separators, null bytes, and unusable names; truncates over-length names to 96 bytes.
  • Known-folder index: folders used by an upload are remembered in the robotstxt_mediafolder_known_folders option (autoload off), sanitized before store and deduplicated, so the picker never needs to scan the filesystem.
  • Folder picker UI on the classic upload screen: existing-folder select, new-folder input, and a live path preview below the dropzone. The choice travels in a hidden form input and is mirrored into the Plupload multipart parameters before every upload, so mid-session changes always apply to the next file.
  • Browser-uploader (HTML4 fallback) support: the picker stays visible in that mode, and its hidden target_folder input posts with the form to media-new.php, whose upload routing now also applies.
  • Drag & drop fix: the media-new.php dropzone posts to async-upload.php’s legacy sync branch (no action parameter), so the routing now recognizes that request shape too.
  • Media Library screen support: the folder picker (“Organize media in folders”) renders inside the Add-media drag & drop frame on upload.php and applies to its uploads.

Compatibility

  • WordPress: 6.9 – 7.1
  • PHP: 8.2 – 8.5 (declared floors provisional until the first-deploy scans)

Tests

  • Plugin header consistency tests (readme.txt, changelog.txt, version constant cross-checks).
  • Uninstall routine test (deletes only the folder index option).