PDF Link Marker
Small WordPress widget + shortcode that swaps a tagged placeholder in a PDF with a user-supplied link and returns a downloadable copy.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/tech-adarshjha/pdflinkeditor/archive/refs/heads/main.zipPDF Link Editor (WordPress)
contains legacy code, update. use as reference only.
Small WordPress widget + shortcode that swaps a tagged placeholder in a PDF with a user-supplied link and returns a downloadable copy. Includes a simple license check hook and a temporary file cleaner.
What this does
- Expects a base PDF at
wp-content/uploads/custom.pdfwith a placeholder tag (default[affid]). - Replaces that tag with a user-provided link (strips
http:///https://), writes a copy, and serves it for download. - Creates a
Tempfolder inside the plugin directory for generated files and deletes files older than 10 minutes. - Provides both a WordPress widget and a
[PDFLINKEDIT]shortcode form.
Requirements
- WordPress with plugin upload rights.
- PHP 7.0+ and permission to create/write
wp-content/plugins/PdfLinkEditor/Temp. - A template PDF at
wp-content/uploads/custom.pdfcontaining the placeholder tag you want replaced.
Quick start
- Copy the plugin folder to
wp-content/plugins/PdfLinkEditor/and activate PDF Link Marker in wp-admin. - Upload your template PDF to
wp-content/uploads/custom.pdf(update the path inincludes/Pdfgenerator*.phpif you keep it elsewhere). - Set your placeholder tag (e.g.,
[affid]) inside the PDF. - Choose one of the usage options below.
Usage
Widget (wp-admin > Appearance > Widgets)
- Drag PDF Link Editor into a sidebar.
- Configure:
License Key: Checked against your license server (see “Licensing notes”).Title: Optional heading above the form.Description above/below: Helper text around the form.Default Tag: Tag that will be replaced in the PDF.
Shortcode
- Insert
[PDFLINKEDIT]into a page or post. - The bundled markup posts to
includes/Pdfgenerator_Shortcode.phpand uses hidden inputs:
[PDFLINKEDIT]
If you want to hand-roll the form, mirror the hidden tag and key fields and POST to Pdfgenerator_Shortcode.php.
What the form does
- Accepts a link, strips protocol, replaces the placeholder tag in the template PDF, and forces a download of the generated file.
File map (quick reference)
PdfLinkEditor.php: Plugin bootstrap, widget registration, shortcode output.includes/PdfLinkEditor-class.php: Widget admin + front-end rendering and license check.includes/Pdfgenerator.php: Handles widget form submission, creates/downloads the PDF copy.includes/Pdfgenerator_Shortcode.php: Same as above but for the shortcode form, with license check.includes/LinkReplacer.php: Simple string replace helper for the PDF content.includes/CleanTempFolder.php: Deletes temp PDFs older than 10 minutes.css/bootstrap.min.css,js/main.js: Enqueued assets.Misc/ShortCode.html: Standalone HTML example of the shortcode form.
Licensing notes
- The code currently points to a local license server (
http://localhost/wordpress) with sample secret keys. UpdateSECRET_KEY,LICENSE_SERVER_URL, and form hiddenkeyvalues before production use. - License checks are performed via simple GET requests; ensure your license server is reachable over HTTPS and that keys are stored securely.
Security and data handling
- Generated PDFs are stored in
wp-content/plugins/PdfLinkEditor/Tempand deleted after ~10 minutes. If you need longer retention or a different path, adjust$PDF_avail_timeand$tempFolderPathinincludes/Pdfgenerator*.php. - Input is lightly sanitized (protocol stripped). For public deployments consider additional validation (allowed domains, length limits) and HTTPS everywhere.
- PDF modification is a plain text replace. It assumes the placeholder exists as text in the PDF; it does not rewrite embedded link objects.
Developing
- Enqueued assets:
PdfLinkEditor-scripts.phphooks Bootstrap +js/main.json the front end. - To change the template path or tag, edit
includes/Pdfgenerator.phpandincludes/Pdfgenerator_Shortcode.php. - Keep PHP error display off in production; current files set
error_reporting(0).
License
This project is provided as it is without warranty. Use at your own risk.