plugin-icon

Oriole One Instant Copy

作者:Rashid Sharafat·
Automatically adds a lightweight, accessible Copy button to every Gutenberg code block. No shortcodes, no database changes.
版本
1.0.0
最后更新
Jun 3, 2026

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).

免费基于付费套餐
通过安装,您同意 WordPress.com 服务条款第三方插件条款
目前已测试版本
WordPress 7.0
这个插件是可用的下载,适用于您的站点。