Built by Nasibul Alam
Add custom CSS, JavaScript, HTML, and PHP snippets — site-wide or per page — with a professional syntax-highlighted editor, device targeting, and full export/import support. No theme file edits. No FTP. Just code that works.
/* 🎨 Global brand snippet — loads on every page */ :root { --brand-primary: #6366f1; --brand-font: 'Inter', sans-serif; } body { font-family: var(--brand-font); }
WDD Custom Code Manager is a WordPress plugin that gives you a centralised, secure place to manage all custom code on your site. Instead of editing functions.php or scattering snippets across theme files, every piece of code lives in a searchable database with its own toggle, scope, priority, and device rules.
CSS, JavaScript, HTML for <head>, <body>, </body>, plus optional PHP execution.
Load any snippet globally or restrict it to specific posts and pages with a live search picker.
Control whether a snippet runs on Desktop, Tablet, Mobile, or any combination — natively.
WordPress's built-in CodeMirror editor with line numbers, bracket matching, and language modes.
Back up every snippet and setting to JSON. Migrate between sites in seconds.
Nonce verification, capability checks, and sanitisation on every input. PHP requires explicit opt-in.
| Requirement | Minimum | Recommended |
|---|---|---|
| WordPress | 5.2 (wp_body_open support) | 6.0+ |
| PHP | 7.4 | 8.1+ |
| MySQL | 5.6 | 8.0+ |
| Browser (admin) | Chrome 80, Firefox 75, Safari 13 | Latest stable |
| User capability | manage_options — administrators only |
Go to WordPress Admin → Plugins → Add New → Upload Plugin. Select the wdd-custom-code-manager.zip file and click Install Now.
/wp-content/plugins/ directory via FTP.Find WDD Custom Code Manager in your plugins list and click Activate. The plugin will automatically create its database table (wp_wdd_ccm_snippets) on first activation.
A new Code Manager menu item appears in your WordPress sidebar. Click it to open the dashboard.
Click Add New Snippet, choose a code type, paste or write your code in the editor, and hit Save Snippet. It goes live immediately.
The plugin adds a Code Manager top-level menu with four sections. Here is a preview of what the snippets list looks like:
The main dashboard shows all your snippets in a table with type badges, scope indicators, device icons, priority, and live status toggles. Use the filter bar to narrow by code type, and the bulk-action dropdown to activate, deactivate, or delete multiple snippets at once.
A two-column editor layout: the left column holds the title, code-type selector, syntax editor, and description. The right sidebar holds the save card, scope picker, device visibility, and priority controls.
Configure PHP snippet execution, login-page suppression, and responsive breakpoint values for device targeting rules.
Download a full JSON backup of all snippets and settings. Re-import on any WordPress site with merge or replace modes.
Every snippet has a type that determines what the code is and where it gets injected in the page lifecycle.
<style> block in <head>. Device visibility is applied via @media queries — zero JavaScript required./* Hide the sidebar on phones */ .sidebar-widget { display: block; } /* WDD device visibility handles the @media wrap automatically */
// Inject a back-to-top button after DOM load document.addEventListener('DOMContentLoaded', function () { var btn = document.createElement('button'); btn.textContent = '↑'; btn.id = 'wdd-scroll-top'; });
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Inter" as="style" />
Every snippet can be either Global (loads on every front-end page) or Specific Pages (loads only on selected posts or pages).
The snippet runs on every page of your site — including archives, search results, and custom post types. This is the default and the right choice for things like brand CSS, analytics scripts, or chat widgets.
In the editor’s right sidebar, switch the Load On card to Specific Pages. A live search field appears — type any page or post title and select it. You can add multiple pages. The snippet will only fire when one of those page IDs matches the current get_queried_object_id().
get_queried_object_id() on every page load — no additional queries are run.Control which screen sizes a snippet renders on. Check any combination of Desktop, Tablet, and Mobile. Leaving all three checked (or all unchecked) means the snippet loads on all devices.
| Code Type | Mechanism | Example output |
|---|---|---|
| CSS | Wrapped in a @media query. | @media screen and (min-width: 1025px) { … } |
| JavaScript | Wrapped in an IIFE with a window.innerWidth guard. | (function(){ if(window.innerWidth < 768){ … } })(); |
| HTML (all) | Server-side check using wp_is_mobile(). | Snippet is skipped entirely if device doesn't match. |
| PHP | Same server-side wp_is_mobile() check. | eval() is skipped; no output is produced. |
The exact pixel values used for media queries and JS guards come from Settings → Device Breakpoints. Defaults:
| Device | Default range | Setting key |
|---|---|---|
| Desktop | ≥ 1025px | desktop_breakpoint |
| Tablet | 768px – 1024px | tablet_breakpoint |
| Mobile | < 768px (auto-calculated) | — (derived) |
wp_is_mobile() classifies tablets as mobile. For HTML and PHP snippets, selecting only Tablet may behave unexpectedly. For precise tablet targeting, use a CSS or JS snippet where device detection is viewport-based.The plugin uses WordPress’s built-in CodeMirror editor, the same one used in the Customizer and Theme Editor. It loads with a custom configuration tuned for each language mode.
| Code Type | CodeMirror Mode |
|---|---|
| CSS | text/css |
| JavaScript | text/javascript |
| HTML Head / Body / Footer | text/html |
| PHP | application/x-httpd-php |
eval(). Only enable this feature if you fully trust the code you are running. Never paste PHP from untrusted sources. This feature requires the manage_options capability and is disabled by default.Go to Code Manager → Settings.
Toggle Enable PHP Snippets to on.
Click Save Settings. The PHP type button now appears in the snippet editor.
You can write PHP with or without opening and closing tags — the plugin strips them automatically before eval().
// Add a custom class to <body> on product pages add_filter('body_class', function( $classes ) { if (is_singular('product')) { $classes[] = 'wdd-product-page'; } return $classes; });
If a PHP snippet contains a syntax error, it is caught with a try/catch block. A debug comment is printed in the page HTML only for logged-in administrators — visitors never see an error.
<!-- WDD CCM: PHP error in snippet "My Snippet": syntax error, unexpected token -->| Setting | Default | Description |
|---|---|---|
| Enable PHP Snippets | Off | Unlocks the PHP code type. Executes code with eval(). Requires deliberate opt-in. |
| Auto-strip PHP tags | Off | Automatically removes <?php and ?> wrappers before executing. |
| Disable on Login Page | Off | Prevents all snippets from loading on wp-login.php. Useful to avoid JS conflicts. |
| Desktop Breakpoint | 1025 | Minimum pixel width for the Desktop device target. Used in CSS @media queries and JS guards. |
| Tablet Breakpoint | 768 | Minimum pixel width for the Tablet device target. Mobile is automatically everything below this value. |
Navigate to Code Manager → Export / Import to back up or restore your snippets.
Click Download Export File. Your browser downloads a timestamped JSON file (e.g. wdd-ccm-export-2024-01-15.json) containing every snippet and your current plugin settings.
{ "plugin": "WDD Custom Code Manager", "version": "1.0.0", "exported": "2024-01-15 14:30:22", "settings": { /* plugin settings object */ }, "snippets": [ { "id": 1, "title": "Global Brand CSS", "code_type": "css", "scope": "global", "device_visibility": "all", "status": 1, "priority": 10 } ] }
Drag and drop a .json export file onto the upload zone, or click Browse File to select it. Then choose an import mode:
You can optionally check Also import plugin settings to restore breakpoint and PHP preferences from the file.
No. Active snippets are fetched in a single database query per page load, cached in a PHP variable for the request lifetime, and output inline at their respective hooks. There are no extra HTTP requests, no JavaScript framework, and no frontend assets loaded unless you have active snippets of that type.
Yes. The plugin outputs code through WordPress’s standard hook system (wp_head, wp_footer, etc.), which is fully respected by WP Rocket, LiteSpeed Cache, W3 Total Cache, and other major caching plugins. CSS and JS are injected inline — they do not create separate files.
Deactivating the plugin simply stops it from running — your snippets remain in the database and will be available when you reactivate. The database table and settings are only removed when you delete the plugin (which runs uninstall.php). Always export your snippets before uninstalling.
Yes. When the active theme does not call wp_body_open(), the plugin starts a PHP output buffer on template_redirect and uses a regex replace to inject the body code immediately after the opening <body> tag. This fallback technique works with virtually all themes.
The importer expects the WDD CCM JSON format. Exports from other plugins (e.g. Code Snippets, WPCode) use different structures and cannot be imported directly. You would need to manually re-add those snippets or write a migration script.
Yes — but be aware of timing. PHP snippets are executed on wp_footer (priority 101), which is after wp_enqueue_scripts, wp_head, and the main page content. Hooks that need to fire earlier in the request lifecycle cannot be registered from a PHP snippet.
Priority controls the order snippets of the same type are output. Lower numbers run first (like WordPress’s add_action priority). The default is 10. If you have two CSS snippets and one needs to override the other, give the overriding snippet a higher number (e.g. 20).
Go to Code Manager → All Snippets, find the snippet in the table, and click Edit. Alternatively, click the snippet title. This loads the editor in edit mode with the existing code pre-filled.
wp_wdd_ccm_snippets) created on activation via dbDelta().@media queries, JS uses window.innerWidth IIFEs, HTML/PHP use wp_is_mobile().try/catch error handling.wp_body_open() support.manage_options capability check on every action.uninstall.php drops the table and removes all plugin options.
Nasibul Alam is a Certified WordPress Developer and Google SEO Expert. He is the Founder and CEO of WebDevDoer and a top-rated freelancer on Fiverr.