https://github.com/alleyinteractive/wp-environment-switcher
Easily switch between hosting environments in WordPress.
https://github.com/alleyinteractive/wp-environment-switcher
wordpress wordpress-plugin
Last synced: about 1 year ago
JSON representation
Easily switch between hosting environments in WordPress.
- Host: GitHub
- URL: https://github.com/alleyinteractive/wp-environment-switcher
- Owner: alleyinteractive
- License: gpl-2.0
- Created: 2023-07-06T20:00:09.000Z (almost 3 years ago)
- Default Branch: develop
- Last Pushed: 2024-12-02T10:17:56.000Z (over 1 year ago)
- Last Synced: 2025-04-30T18:49:28.770Z (about 1 year ago)
- Topics: wordpress, wordpress-plugin
- Language: PHP
- Homepage:
- Size: 1.73 MB
- Stars: 3
- Watchers: 20
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# WordPress Environment Switcher
[](https://github.com/alleyinteractive/wp-environment-switcher/actions/workflows/coding-standards.yml)
Easily switch between different site environments from the WordPress admin bar.
> Props to [WordPress Stage Switcher](https://github.com/roots/wp-stage-switcher) for the inspiration.
## Installation
You can install the package via Composer:
```bash
composer require alleyinteractive/wp-environment-switcher
```
## Usage
Activate the plugin in WordPress and you will see the switcher appear in the top right admin bar:

The plugin reads the current WordPress environment from the current hosting
provider (Pantheon and WordPress VIP supported) and falls back to
`wp_get_environment_type()` which can be set by defining `WP_ENVIRONMENT_TYPE`
in your `wp-config.php` file. You can override the current environment by
using the `wp_environment_switcher_current_environment` filter:
```php
add_filter(
'wp_environment_switcher_current_environment',
fn () => 'my-custom-environment'
);
```
You can define the available environments by using the
`wp_environment_switcher_environments` filter:
```php
add_filter(
'wp_environment_switcher_environments',
fn () => [
'production' => 'https://example.org',
'staging' => 'https://staging.example.org',
'local' => 'https://example.test',
]
);
```
The plugin will automatically detect the current environment and highlight it in
the switcher. By default, the plugin will show the switcher to anybody with the
`manage_options` capability. You can change this by modifying the capability
mapped to the `view_environment_switcher` capability with `map_meta_cap`.
## Testing
Run `composer test` to run tests against PHPStan/PHPCS.
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
This project is actively maintained by [Alley
Interactive](https://github.com/alleyinteractive). Like what you see? [Come work
with us](https://alley.com/careers/).
- [Sean Fisher](https://github.com/srtfisher)
- [All Contributors](../../contributors)
## License
The GNU General Public License (GPL) license. Please see [License File](LICENSE) for more information.