Admin Theme Switcher
Lightweight WordPress plugin to enhance admin experience
by Reza Qalekhani · github.com/reza-qalekhani/admin-theme-switcher · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/reza-qalekhani/admin-theme-switcher/releases/download/v1.1/admin-theme-switcher-1.1.zipReadme
Admin Theme Switcher 🚀
A lightweight WordPress plugin that adds a dark/light mode switcher and customizable admin font family selector to the WordPress admin dashboard.
📝 Description
Admin Theme Switcher enhances the WordPress admin experience with two key features:
- Dark Mode Toggle — A quick-access button in the admin bar to switch between light and dark themes. User preference is saved per user.
- Admin Font Selector — A settings page to choose from multiple font families for the admin interface, including support for Persian fonts like Vazirmatn, IranSansX, and IranYekan.
✨ Features
Dark Mode Toggle
- Admin Bar Button — Quick toggle in the admin bar (displays ☀️ or 🌙 based on current mode)
- AJAX-Based — Instant switching without page reload
- Per-User Preference — Each user's preference is stored independently
- Block Editor Support — Styles apply to both classic admin and block editor iframe
- Nonce Protected — AJAX requests are secured with WordPress nonce verification
Font Settings
- Settings Page — Dedicated settings page under Settings → Admin Appearance
- Multiple Font Options — Choose from Default, Vazirmatn, IranSansX, or IranYekan
- Admin-Only — Requires
manage_optionscapability - Persistent Storage — Font choice is saved as a WordPress option
- Block Editor Support — Custom fonts apply to the block editor canvas
- Font Fallback — Missing font files safely fall back to sans-serif
💻 Requirements
- PHP: 7.0 or higher
- WordPress: 5.0 or higher
🛠️ Installation
- Download the plugin files
- Upload the
admin-theme-switcherfolder to/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to Settings → Admin Appearance to configure custom font families
⚙️ Configuration
1. Dark Mode
Dark mode settings are stored per user in user meta (ats_dark_mode). No configuration required — users can toggle in the admin bar.
2. Font Selection
- Go to Settings → Admin Appearance in the WordPress admin
- Select your preferred font family
- Click Save Changes
3. Adding Custom Fonts
To use custom fonts instead of the defaults:
-
Add font files to
assets/fonts/with these filenames:font-option-1.woff2— Used by "Font Option 1"font-option-2.woff2— Used by "Font Option 2"font-option-3.woff2— Used by "Font Option 3"
-
Update font labels in
includes/class-font-settings.php:public static function get_font_labels() { return array( 'default' => __('Default', 'admin-theme-switcher'), 'customfont' => __('My Custom Font', 'admin-theme-switcher'), // ... ); } -
Update SCSS in
assets/scss/admin-fonts.scss:@font-face { font-family: "CustomFont"; src: url("../fonts/font-option-1.woff2") format("woff2"); } .ats-font-customfont { --wp-admin-font: "CustomFont", sans-serif; } -
Rebuild CSS:
npm run build
🚀 Usage
Using Dark Mode Toggle
- Look for the dark/light mode icon (☀️ or 🌙) in the WordPress admin bar
- Click to toggle between dark and light modes
- Your preference is automatically saved to your user profile
- Styles apply immediately without page reload
Using Font Selector
- Navigate to Settings → Admin Appearance
- Select your preferred font family from the radio buttons
- Click Save Changes
- The font applies to all admin pages for all users (global setting)
Using Custom Fonts
- Place font files in
assets/fonts/folder - Update font options in
includes/class-font-settings.php - Update CSS classes in
assets/scss/admin-fonts.scss - Run
npm run buildto compile SCSS - Clear cache and refresh to see changes
📁 Project Structure
admin-theme-switcher/
├── admin-theme-switcher.php # Main plugin file with hooks
├── uninstall.php # Cleanup on plugin uninstallation
├── package.json # Build dependencies (Node.js/SASS)
├── assets/
│ ├── css/ # Compiled CSS files
│ │ ├── dark-mode.css # Dark mode styles
│ │ └── admin-fonts.css # Font styles
│ ├── js/
│ │ └── dark-mode-toggle.js # AJAX toggle handler
│ ├── scss/ # Source SCSS files
│ │ ├── dark-mode.scss # Dark mode SCSS
│ │ └── admin-fonts.scss # Font SCSS
│ └── fonts/ # Font files (WOFF2 format)
├── includes/
│ ├── class-dark-mode.php # Dark mode toggle functionality
│ └── class-font-settings.php # Font settings page & logic
├── languages/ # Internationalization
│ ├── admin-theme-switcher.pot # Translatable strings template
│ └── admin-theme-switcher-fa_IR.po # Farsi translation
└── README.md # This file
🌍 Internationalization
The plugin is fully internationalized with:
- Text domain:
admin-theme-switcher - Language files location:
/languages/ - Currently supported: English, Persian (Farsi)
Translation Files
admin-theme-switcher.pot— Translation template for translatorsadmin-theme-switcher-fa_IR.po— Persian source translationsadmin-theme-switcher-fa_IR.mo— Persian compiled translations
To add new language support, create a .po file in the /languages/ directory following WordPress translation conventions.
🧪 Development
Building Assets
Install dependencies:
npm install
Build minified CSS from SCSS:
npm run build
Watch for changes during development:
npm run watch
Technologies Used
- PHP 7.0+ — Plugin core logic
- JavaScript (Vanilla) — Dark mode AJAX toggle
- SCSS — Stylesheets (compiled to CSS)
- Node.js + SASS — Build process
Code Architecture
Main Plugin File (admin-theme-switcher.php):
- Defines plugin constants and version
- Loads text domain for translations
- Initializes the two main classes
Dark Mode Class (includes/class-dark-mode.php):
- Manages dark mode user preference (stored in user meta)
- Adds admin bar toggle button
- Handles AJAX requests for toggling
- Enqueues dark mode styles and JavaScript
Font Settings Class (includes/class-font-settings.php):
- Registers a settings page under Settings menu
- Handles font selection radio buttons
- Stores font preference as WordPress option
- Applies font class to admin body element
Hooks & Filters
| Hook | Used For |
|---|---|
init |
Load text domain for translations |
admin_bar_menu |
Add dark mode toggle button |
admin_enqueue_scripts |
Load CSS/JS on admin pages |
enqueue_block_assets |
Load styles in block editor iframe |
admin_body_class |
Apply CSS classes for dark mode and font |
wp_ajax_ats_toggle_mode |
Handle AJAX toggle requests |
admin_menu |
Register font settings page |
admin_init |
Register font settings |
🚀 Build & Release
Version Management
Current version: 1.1
Plugin files to update for new releases:
admin-theme-switcher.php— Update version in plugin header and constants- Create/update changelog in documentation
Release Process
- Update version number in
admin-theme-switcher.php - Test all features thoroughly
- Update documentation if needed
- Commit changes with version tag
Manual Build for Distribution
npm install
npm run build
# Create plugin directory and build ZIP
mkdir -p build/admin-theme-switcher
rsync -av --exclude-from=.distignore ./ build/admin-theme-switcher/
cd build && zip -r admin-theme-switcher.zip admin-theme-switcher/
🐛 Troubleshooting
Dark Mode Toggle Not Appearing
- Ensure the plugin is activated
- Check that you're logged in as a user
- Look in the admin bar (top-left area)
Custom Fonts Not Loading
- Verify font files are in
assets/fonts/with correct filenames - Check browser console for CORS or 404 errors
- Rebuild CSS:
npm run build - Clear browser cache and WordPress object cache
Styles Not Applying
- Clear the WordPress plugin cache
- Rebuild CSS assets:
npm run build - Check that
admin-theme-switcher.phpversion constant matches compiled files
🤝 Contributing
Contributions are welcome! When contributing:
- Follow WordPress coding standards
- Test your changes thoroughly
- Ensure internationalization compatibility
- Document new features
📜 License
This plugin is open-source and free to use, modify, and distribute.
👨💻 Author
Reza Qalekhani
- Website: byreza.net
- Channel: @byreza_net
- Telegram ID: @reza_qalekhani
❤️ Show Your Support
If you find this project useful, please:
- ⭐ Give it a star on GitHub
- 🔗 Share it with your network
- 💬 Leave feedback and suggestions
- 🐛 Report bugs and issues
Made with ❤️ by Reza Qalekhani
Last Updated: 2026-06-18
Read the full README on GitHub →
Releases
| Tag | Published | Asset | Downloads |
|---|---|---|---|
| v1.1 | Jun 17, 2026 | admin-theme-switcher-1.1.zip | 2 |