Oriole One Instant Copy

Description

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-label support, focus-visible outlines, 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 to execCommand('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 currentColor and 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).

Installation

Automatic (recommended)

  1. In your WordPress admin, go to Plugins Add New.
  2. Search for Oriole One Instant Copy.
  3. Click Install Now, then Activate.

Manual

  1. Download the plugin zip file.
  2. Go to Plugins Add New Upload Plugin.
  3. Upload the zip, then click Install Now and Activate.

From source

  1. Upload the oriole-one-instant-copy folder to /wp-content/plugins/.
  2. 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: absolute to overlay the button, so it does not affect your theme layout. Colours are set using currentColor and 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.

What happens if another plugin already adds a Copy button?

If a copy button with the class oriole-oic-copy-btn already 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.clipboard API requires a secure context (HTTPS or localhost). On non-secure HTTP pages, the plugin automatically falls back to document.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 .pot file is included in the languages/ 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_options with the key oriole_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.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Oriole One Instant Copy” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.0

  • Initial release.
  • Auto-injects accessible Copy button on all pre.wp-block-code elements.
  • Settings page with enable toggle, custom button text, and custom success text.
  • navigator.clipboard with execCommand fallback.
  • Keyboard accessible with focus-visible outline and aria-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.