| 开发者 | ramirkz |
|---|---|
| 更新时间 | 2026年10月19日 22:24 |
| PHP版本: | 8.0 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
.copy-me
If your page contains:
<span class="copy-me">PROMO-2026</span>
the visitor can copy PROMO-2026 by activating that element.
Choosing what gets copied
The plugin uses the first applicable source below.
1. Explicit value with data-copy-value
Use this when the visible label is different from the value that should be copied.
<button class="copy-me" data-copy-value="PROMO-2026">Copy promo code</button>
Copied value: PROMO-2026
2. Another element with data-copy-target
Use a local ID reference beginning with #.
<input id="account-number" value="UA123456789">
<button class="copy-me" data-copy-target="#account-number">Copy account number</button>
Copied value: the current value of #account-number.
3. Form controls
If a matching element is an input, textarea or select field, the plugin copies its current value.
4. Normal page content
For other matching elements, the plugin copies the element's visible text content.
Shortcode and block
Place a copy button anywhere, without configuring selectors:
[koz_copy text="PROMO-2026" label="Copy code" /]
Show the value itself as clickable inline text:
[koz_copy display="inline"]UA123456789[/koz_copy]
Copy the current value of another element:
[koz_copy target="#account-number" label="Copy account number" /]
Close single shortcodes with /]. Without it, WordPress treats a later [/koz_copy] on the same page as the end of the earlier shortcode and the enclosed shortcodes disappear.
Attributes: text, target, label, display (button or inline), format (text or html), key (sent with the copy event) and class.
In the block editor, add the Copy button block and set the value, label and display in the block settings.
The shortcode and block work on every page where they are placed, independently of the selector settings and display conditions.
Copy buttons for code blocks
In Add a copy button to, list elements that should receive a separate Copy button, for example:
pre
Allowed entries: pre, code, blockquote, kbd, samp, a class or ID, or one of these tags combined with a class or ID (for example pre.wp-block-code). Whitespace inside these elements is always preserved, so copied code keeps its indentation.
Formatted copying
With Copy format set to Formatted (HTML and text), element content is copied as HTML and plain text together, so links, bold text and lists survive when pasting into editors that support formatting. Explicit values and form fields are always plain text. Override one element with data-copy-format="text" or data-copy-format="html".
Supported selectors
For safety and predictable behaviour, settings accept simple selectors only:
.copy-me#copy-code[data-copy-value], [data-copy-target], [data-copy-key] and [data-uafree-copy]/contact/
/donate/
/products/*
An ending * matches all paths beginning with that prefix.
You can also limit the handler to single views of selected post types, or to specific post or page IDs. When paths, post types or IDs are set, the handler loads where any of them matches.
For multilingual sites with language-specific URLs, add each required language path, for example:
/en/contact/
/uk/kontakty/
Accessibility and feedback
KOZ Copy Actions can:
koz-copy-actions text domain.
Admin labels and frontend messages such as Copied, Could not copy and Copy to clipboard use WordPress translation functions and remain compatible with the standard WordPress.org translation system.
Version 1.1.13 also includes the KOZ Suite runtime language baseline: Ukrainian, Chinese, Spanish, Arabic, Indonesian, Portuguese, French, Japanese, German and Hindi, with English fallback. The WordPress user locale controls the administration interface. On the frontend, supported language-prefixed routes use the matching bundled copy feedback language.
The copy logic itself is language-independent: it works with the rendered content of the current page, so the same selector configuration can be used with multilingual plugins and translated pages.
If your multilingual setup uses different URL paths for each language and you use Allowed paths, add the corresponding path for each language.
KOZ Copy Actions does not translate the content being copied. It copies the value or text that is already rendered on the current page.
Privacy
Clipboard operations happen in the visitor's browser.
The plugin does not:
No. If your page builder, block editor or theme lets you add a CSS class or supported data attribute to an element, you can normally configure the copy action without editing PHP.
.copy-me as a selector?Every public element with the class copy-me becomes a copy target on allowed pages. Normal text elements copy their rendered text. Form controls copy their current value.
Yes. Add data-copy-value to the matching element.
Yes. Use data-copy-target="#element-id" and make sure the referenced element has that ID.
The plugin does not require a specific multilingual integration. It operates on the rendered frontend content and simple selectors, so it can work on translated pages. If you restrict copy actions by URL path, configure the required path for each language.
No. It copies the content already displayed on the current page.
Yes. User-facing strings are internationalized with the koz-copy-actions text domain and are compatible with the WordPress.org translation system.
No. Clipboard operations are performed locally in the browser and copied values are not sent to the developer or an external service.
Yes. Enable Prevent navigation when a matching link is clicked in the plugin settings.
[koz_copy] shortcode and Copy button block (Block API v3, compatible with the iframe editor) for copy buttons or inline copy text without CSS selectors.pre code blocks.data-copy-format override.closest() call.defer strategy on WordPress 6.3+, and settings migration runs only in the administration area.