WP Manifestindependent plugin directory
manifest / developer / code-snippets-copier

Code Snippets Copier

Register a CPT to store raw shortcodes. Provide AJAX + frontend JS to copy snippets by ID to clipboard.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/rameezwp/code-snippets-copier/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Easily create and copy shortcode/code snippets to the clipboard via AJAX with one click. Store snippets in a custom post type and insert copy buttons anywhere.

Description

Code Snippets Copier allows site admins to create reusable code or shortcode snippets in a custom post type, and let visitors copy them with a single click.
No more escaping quotes or manually pasting — snippets are stored safely in the editor and copied raw via AJAX.

✨ Features

  • Custom Post Type "Code Snippets" with title + content (where you add your code/shortcode).
  • Frontend copy buttons using AJAX (no rendering, just raw snippet text).
  • Shortcode helper [wcp_code_copy_btn id="123" label="Copy Code"].
  • Supports multiple buttons on a single page.
  • Secure: only published snippets are publicly available, drafts are restricted.
  • Clipboard API with fallback for older browsers.

🎯 Use cases

  • Share shortcodes for WPBakery/Elementor demos.
  • Provide code samples in tutorials or documentation.
  • Distribute reusable snippets to your clients/users.

Installation

  1. Upload the plugin files to /wp-content/plugins/code-snippets-copier/ or install via WordPress Admin → Plugins → Add New.
  2. Activate the plugin.
  3. Go to Code Snippets in the WordPress admin menu, click Add New, and paste your code/shortcode into the editor.
  4. Publish the snippet.
  5. Insert a copy button anywhere using:

Shortcode: [wcp_code_copy_btn id="123" label="Copy Code"]

Frequently Asked Questions

How do I find the snippet ID?

Edit your snippet in the admin and look at the URL: post=123 → the ID is 123.

Does it execute shortcodes or code?

No. It returns the raw content exactly as you entered, so users can copy/paste it.

Does it work on HTTP sites?

Yes, but on insecure sites the modern navigator.clipboard API may not be available. The plugin falls back to execCommand('copy') and finally a manual prompt.

Can I style the buttons?

Yes, the output is a simple with class sc-copy-btn. Style it with CSS or add extra classes via shortcode: [wcp_code_copy_btn id="123" class="btn btn-primary"]