Focused WordPress plugins for real client work.Clear licensing for 1, 5, or 100 websites

Code Snippets documentation

Help and reference for version 1.1.0.

Overview

Dprime Code Snippets lets you add small pieces of code to your site without editing theme or plugin files. Each snippet has a type, a location, a priority, and an on or off switch.

Four snippet types:

Where a snippet runs:

Requirements

  • WordPress 6.4 or newer
  • PHP 8.2 or newer

Installation

  1. Upload the plugin folder to the /wp-content/plugins/ directory, or install it through the Plugins screen.
  2. Activate the plugin.
  3. Open Code Snippets from the admin menu and add your first snippet.

Using the plugin

  • PHP runs as server code
  • CSS is printed inside a style tag
  • JavaScript is printed inside a script tag
  • HTML is printed as is
  • PHP snippets run everywhere, on the frontend only, or in the admin only
  • CSS and JavaScript snippets load on the frontend, in the admin, or both
  • HTML snippets print in the site header or the site footer

Data and cleanup

  • 2 WordPress settings

Retention: kept until the plugin is uninstalled. Uninstall policy: delete the plugin-owned data declared above.

Frequently asked questions

What happens if my PHP snippet has an error?

New PHP snippets are checked for syntax before they save. If a snippet throws an error while running, the plugin catches it, turns the snippet off, and shows the message on the snippets list. Fix the code and turn the snippet back on.

A snippet locked me out of the admin. What now?

Add define('DPCS_SAFE_MODE', true); to your wp-config.php file. No snippet runs while safe mode is on, so you can reach the admin, turn off the snippet, and remove the line.

When do PHP snippets run?

PHP snippets run early, on the plugins_loaded hook. For code that depends on the theme or on WooCommerce, wrap it in an action such as init or wp so it runs at the right time.

Can I move snippets between sites?

Yes. Use Export on the Tools tab to download a JSON file, then Import on the other site. Imported snippets are turned off until you activate them.

Updates and access

This complete free release can be downloaded directly. Install Dprime Core for automatic catalogue updates.