What You’ll Learn
- Adding custom PHP, CSS, and JavaScript to your Dashboard
- Where custom code is stored and executed
- Using the built-in code editor (CodeMirror 6) with autocompletion, code folding, and the One Dark theme
- Validating PHP snippets before saving with the built-in syntax check
- Handling PHP errors safely
- Accessing example code snippets
Extension Add-on - This add-on provides standalone functionality within MainWP Dashboard. No third-party plugins required.
The MainWP Custom Dashboard Extension is designed to contain your custom snippets for your MainWP Dashboard.
By adding custom snippets to this plugin, you can easily extend your MainWP Dashboard functionality or change the way it looks.
After activation, open it from Add-ons > Administrative > Custom Dashboard in MainWP Dashboard.

How It Works
MainWP Custom Dashboard Extension saves your PHP, CSS, and JS snippets in WordPress options on your MainWP Dashboard site instead of requiring separate PHP, CSS, or JS files. CSS and JS snippets are added inline on MainWP pages only — they don’t load on the rest of WP Admin or the front-end. Saved PHP Code Snippets are executed on page load using the PHP functioneval().
In case the eval() function is disabled on your host, please contact your host support and have them enable it for you.
MainWP Custom Dashboard Extension is used to apply custom code snippets to the MainWP Dashboard site ONLY!
It doesn’t apply code to child sites.
To apply custom code snippets to child sites, please see the MainWP Code Snippets Extension.
The Code Editor
The editor is powered by CodeMirror 6 and ships with productivity features enabled by default:- Syntax highlighting for PHP, CSS, and JavaScript
- One Dark theme for better readability
- Autocompletion as you type
- Automatic bracket closing for
(),{},[], and quotes - Code folding with gutter handles and keyboard shortcuts
- Tab indentation that respects natural tab behavior inside the editor
Writing PHP Snippets
PHP snippets are saved as tagless PHP — write your code without<?php or ?> tags. The extension validates this on save and rejects snippets that contain PHP tags.
Pre-save syntax validation
Before a PHP snippet is saved, the extension runs a syntax check on the code. If the snippet contains a parse error, the save is rejected and the editor displays the error message so you can fix it before it ever runs. This catches the most common cause of a broken dashboard — a typo in a snippet — without you having to reload the page to find out.Runtime error handling
If a saved PHP snippet still produces a parse or compile fatal error at runtime, the extension catches it and shows a safe error message with a link back to the PHP editor. Snippet execution is disabled until you fix the code:
Throwables) thrown by a snippet are caught and logged instead of taking down the page.
Related Resources
- Development Add-ons - Browse all development tools
- Code Snippets Extension - Deploy code to child sites
- Dashboard Themes - MainWP Dashboard appearance and theme behavior
