wp-media / wp-media/backwpup

Copy button for trigger link fails in HTTP context (Clipboard API unavailable)

Open
#236 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
95
Forks
46
PR merge metrics
No merged PRs in 30d

Description

Summary

The "Copy" button for the trigger link does not work in certain environments.
Clicking the button throws a JavaScript error and the link is not copied to the clipboard.

Additionally, the trigger link is truncated in the UI, making manual copying impossible.

This issue appears to be related to the availability of the Clipboard API.


Steps to Reproduce
  1. Open an existing BackWPup job
  2. Click on "Frequency"
  3. Select "Triggered by link"
  4. A trigger link and "Copy" button are displayed
  5. Click the "Copy" button

Expected Behavior
  • The full trigger link is copied to the clipboard
  • Optional: user receives visual feedback (e.g. tooltip or message)

Actual Behavior
  • Clicking the "Copy" button does nothing
  • No UI feedback is shown
  • The link is not copied
  • The following error appears in the browser console:
Uncaught TypeError: Cannot read properties of undefined (reading 'writeText')
at HTMLDocument.<anonymous> (backwpup-admin.js:2535)
  • The trigger link is truncated (...) in the UI and cannot be copied manually

Root Cause (Analysis)

The issue occurs when the Clipboard API is not available.

In environments where the WordPress admin is served over HTTP (not HTTPS), navigator.clipboard is undefined because the Clipboard API is only available in secure contexts (HTTPS or localhost).

This explains why the issue cannot be reproduced in HTTPS environments.


Suggested Fix

Add a guard before calling the Clipboard API and optionally provide a fallback:

if (navigator.clipboard && navigator.clipboard.writeText) {
  // Modern Clipboard API (secure contexts only)
  navigator.clipboard.writeText(text);
} else {
  // Clipboard API not available (e.g. HTTP or older browsers)

  // Option 1: implement fallback (e.g. document.execCommand('copy'))
  // Option 2: disable/hide copy button
  // Option 3: show full link to allow manual copying
}

Additional UX Issue

The trigger link is truncated in the UI (...), which makes manual copying impossible.

Even if the truncation is intentional for layout reasons, users should still be able to:

  • copy the full link manually, or
  • access it via an alternative UI (e.g. input field)

Environment
  • BackWPup: 5.6.6
  • WordPress: 6.9.1
  • Browser: Chrome 145, Firefox 148

Screenshot showing the problem


References

Original WordPress support thread:
https://wordpress.org/support/topic/copy-button-for-the-trigger-link-does-not-work/


Notes

The issue has been confirmed in HTTP environments and acknowledged in the support thread.
It is likely not a browser limitation but expected behavior of the Clipboard API.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at backwpup-admin.js around line 2535, where the trigger-link Copy button calls the Clipboard API, and reproduce the flow from an existing job's Frequency settings. Check the HTTP case where navigator.clipboard is unavailable and the truncated trigger link display. Done means copying no longer throws an error in that context and the full link remains accessible for manual copying or an equivalent fallback.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wordpress
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.