=== Dprime Code Snippets ===
Contributors: dprime
Tags: code snippets, php, css, custom code, javascript
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.2
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Run custom PHP, CSS, JavaScript, and HTML from the admin, with a syntax check and a fatal error guard that turns a broken snippet off before it locks you out.

== Description ==

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:

* PHP runs as server code
* CSS is printed inside a style tag
* JavaScript is printed inside a script tag
* HTML is printed as is

Where a snippet runs:

* 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

Safety comes first. A PHP snippet is checked for syntax before it is saved. If a snippet still fails when it runs, the plugin catches the error, turns the snippet off, and records the message so the next page load recovers on its own. If a snippet ever locks you out of the admin, a one line safe mode switch in wp-config.php stops every snippet so you can get back in.

Snippets can be exported to a JSON file and imported on another site. Imported snippets always arrive turned off so you can review each one before you activate it.

Only administrators can add or run snippets. Snippet code runs with full site privileges, so treat it with the same care as editing plugin files by hand.

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

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

== Changelog ==

= 1.0.1 =
* Fixed the Add snippet button showing dark text on its dark background.
* Replaced the type filter and scope dropdown arrows with a clearer icon.

= 1.0.0 =
* First release.
