설명
Oriole One Instant Copy enhances the standard WordPress Gutenberg Code block (core/code) by injecting a small, accessible “Copy” button into the top-right corner of every code block on your site — automatically, on every existing and future post.
No shortcodes. No block-editor changes. No database modifications. Pure progressive enhancement.
How it works
The plugin uses vanilla JavaScript to detect every pre.wp-block-code element after the page loads and appends a lightweight Copy button. When clicked, the button copies the code text to the system clipboard using the modern navigator.clipboard API, with a document.execCommand fallback for older browsers.
The stored post content is never touched. If you deactivate or uninstall the plugin, your posts are exactly as they were before.
Key Features
- Automatic — works on all existing and future posts without any editor involvement.
- Lightweight — total asset footprint under 5 KB combined (CSS + JS). Zero dependencies.
- Accessible — keyboard navigable,
aria-labelsupport,focus-visibleoutlines, screen-reader text, reduced-motion aware, high-contrast mode support. - Smart enqueueing — assets are loaded only on pages that actually contain a Gutenberg code block, not on every page of your site.
- Clipboard API with fallback — uses
navigator.clipboard.writeText()on secure contexts and falls back toexecCommand('copy')for legacy environments. - Duplicate-proof — skips any code block that already has a copy button to avoid conflicts with other plugins.
- Theme-safe — uses
currentColorand semi-transparent backgrounds; works with light and dark themes without hardcoding colours. - No jQuery — vanilla JavaScript only.
- No tracking, no telemetry, no external requests — 100% self-hosted.
- Multisite compatible.
Settings
Find the settings under Settings Oriole One Instant Copy:
- Enable / Disable the button globally.
- Button text — customise the label shown on the button (default: “Copy”).
- Success text — customise the label shown after copying (default: “Copied!”).
- Position — Top Right (additional positions planned for v2).
Developer Notes
All settings use the WordPress Settings API with sanitize_callback and proper nonce handling via settings_fields(). No custom REST endpoints, no Gutenberg/React dependencies, no build tools required.
The plugin defines the following PHP constant and classes:
ORIOLE_OIC_VERSION— current plugin version string.Oriole_OIC_Plugin— main bootstrap class (singleton).Oriole_OIC_Settings— settings page and storage class.
Option stored in wp_options: oriole_oic_settings (autoloaded, single serialised array).
설치
Automatic (recommended)
- In your WordPress admin, go to Plugins Add New.
- Search for Oriole One Instant Copy.
- Click Install Now, then Activate.
Manual
- Download the plugin zip file.
- Go to Plugins Add New Upload Plugin.
- Upload the zip, then click Install Now and Activate.
From source
- Upload the
oriole-one-instant-copyfolder to/wp-content/plugins/. - Activate the plugin through the Plugins screen in WordPress.
No additional configuration is required. The Copy button will appear immediately on all pages containing Gutenberg code blocks.
FAQ
-
Does this work with the Classic Editor?
-
The plugin targets
pre.wp-block-code, which is the HTML class added exclusively by the Gutenberg (Block Editor) Code block. Classic Editor<pre>tags will not be affected. -
Will it work with my theme?
-
Yes. The plugin uses
position: absoluteto overlay the button, so it does not affect your theme layout. Colours are set usingcurrentColorand semi-transparent layers, making the button readable on virtually any background. -
Does it conflict with syntax highlighting plugins (e.g. Prism.js, Highlight.js)?
-
No. The plugin appends a button element to the
<pre>container but does not modify the<code>content or any of its attributes. Syntax highlighting plugins operate on the code text and are unaffected. -
If a copy button with the class
oriole-oic-copy-btnalready exists inside a code block, this plugin will skip it. This prevents duplicate buttons when used alongside other copy plugins. -
Does it slow down my site?
-
The impact is negligible. The CSS and JS files are each under 5 KB. Assets are only enqueued on pages that contain at least one Gutenberg code block, so other pages are completely unaffected.
-
Does it work on HTTPS only?
-
The
navigator.clipboardAPI requires a secure context (HTTPS or localhost). On non-secure HTTP pages, the plugin automatically falls back todocument.execCommand('copy'), which works in most modern browsers regardless of protocol. -
Is it multisite compatible?
-
Yes. Settings are stored per site. On uninstall, options are removed from every site in the network.
-
Can I translate it?
-
Yes. The plugin is fully internationalised using standard WordPress i18n functions. A
.potfile is included in thelanguages/directory. Translations can be submitted via translate.wordpress.org. -
Where are the settings?
-
WordPress Admin Settings Oriole One Instant Copy.
-
What data does the plugin store?
-
Only one row in
wp_optionswith the keyoriole_oic_settings. It stores your button text, success text, position preference, and the enabled/disabled toggle. The option is removed cleanly when you delete the plugin. -
Does the plugin phone home or load external resources?
-
No. There are no external HTTP requests, no CDN-loaded assets, no analytics, no telemetry, and no licence checks of any kind.
후기
이 플러그인에 대한 평가가 없습니다.
기여자 & 개발자
자국어로 “Oriole One Instant Copy”(을)를 번역하세요.
개발에 관심이 있으십니까?
변경이력
1.0.0
- Initial release.
- Auto-injects accessible Copy button on all
pre.wp-block-codeelements. - Settings page with enable toggle, custom button text, and custom success text.
navigator.clipboardwithexecCommandfallback.- Keyboard accessible with
focus-visibleoutline andaria-label. - Reduced-motion and forced-colour (high-contrast) CSS support.
- Smart asset enqueueing: loads only on pages with code blocks.
- Duplicate-button guard for coexistence with other copy plugins.
- Multisite-aware uninstall cleanup.