ToolDocs is a document management plugin for WordPress that lets you upload, organize, and share documents with your visitors through direct permalinks.
Key Features:
Shortcodes:
[tooldocs_file id="X"] – Display a single document download link with file type icon[tooldocs_category_files category_id="Y"] – Display all documents in a category, with optional modal popupHow It Works:
The admin interface is built with Vue.js. Source code is included in the admin/src/ directory.
Frontend JavaScript source is in front/.
To build the admin interface:
1. Navigate to the admin/ directory
2. Run npm install
3. Run npm run build
To build the frontend JavaScript:
1. Navigate to the front/ directory
2. Run npm install
3. Run npm run build
The document download template is a public-facing page with no authentication or access restrictions – all documents are freely downloadable. The h parameter is simply a unique file identifier (like a post slug), and src is a tracking parameter similar to UTM parameters. These URLs are distributed in emails, press releases, and external sites, so they cannot be bound to a WordPress nonce (which would expire and require an active session to generate). Both $_GET parameters are sanitized with sanitize_text_field(wp_unslash()) and the hash is validated against the database before any file operation.
The echo fread() on this line streams raw binary file data (PDFs, ZIPs, documents, etc.) to the browser. Escaping binary data would corrupt the file. The Content-Type header is set from the WordPress media library MIME type, and the file path is resolved from a validated database record. This is the standard pattern for file streaming in PHP and cannot be escaped.
The DONOTCACHEPAGE constant is only defined on the specific ToolDocs download page, not globally. It is set inside a conditional that checks get_queried_object_id() against the stored download page ID. This is a standard WordPress cache-busting constant recognised by all major caching plugins, and it is necessary to ensure download tracking fires on every visit to the download page.