https://github.com/fabrikage/wp-env-switcher
Use this package to add a menu item in your WordPress admin bar in which you can switch between environments. This is useful when you have a DTAP street and you want to quickly switch between your environments.
https://github.com/fabrikage/wp-env-switcher
php php8 wordpress wordpress-development
Last synced: about 1 month ago
JSON representation
Use this package to add a menu item in your WordPress admin bar in which you can switch between environments. This is useful when you have a DTAP street and you want to quickly switch between your environments.
- Host: GitHub
- URL: https://github.com/fabrikage/wp-env-switcher
- Owner: fabrikage
- Created: 2023-12-09T13:21:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-09T13:30:49.000Z (over 2 years ago)
- Last Synced: 2025-06-03T14:45:13.986Z (about 1 year ago)
- Topics: php, php8, wordpress, wordpress-development
- Language: PHP
- Homepage: https://fabrikage.nl
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#
fabrikage/wp-env-switcher
Use this package to add a menu item in your WordPress admin bar in which you can switch between environments. This is useful when you have a DTAP street and you want to quickly switch between your environments.
\
The library will compare your current URL with the environment URLs you have set in your environment variables. If the current URL matches one of the environment URLs, that environment will be marked as active. Other environments will show in the submenu.
## Screenshot

## Requirements
Set the following `$_ENV` variables in your project:
```bash
URL_DEVELOPMENT='https://example.dev'
URL_TESTING='https://example.test'
URL_ACCEPTANCE='https://example.acceptance'
URL_PRODUCTION='https://example.com'
```
*Note: These variables are not required, but if you don't set them, the corresponding menu item will not show up.*
## Installation
Install the package using composer:
```bash
composer require fabrikage/wp-env-switcher
```
## Usage
Add the following code to your `functions.php`:
```php
\Fabrikage\WordPress\EnvSwitcher::enable();
```
If you want to enable the menu for specific users, pass an array with usernames:
```php
\Fabrikage\WordPress\EnvSwitcher::enable(['admin', 'other-user']);
```