roots / wp-stage-switcher
WordPress plugin that allows you to switch between different environments from the admin bar
Package info
github.com/roots/wp-stage-switcher
Type:wordpress-plugin
pkg:composer/roots/wp-stage-switcher
Fund package maintenance!
Requires
- php: >=8.2
- composer/installers: ~1.0 || ~2.0
Requires (Dev)
- laravel/pint: ^1.20
- pestphp/pest: ^2.36 || ^3.0 || ^4.0
This package is auto-updated.
Last update: 2026-03-09 22:01:20 UTC
README
A WordPress plugin that allows you to switch between different environments from the admin bar.
Support us
We're dedicated to pushing modern WordPress development forward through our open source projects, and we need your support to keep building. You can support our work by purchasing Radicle, our recommended WordPress stack, or by sponsoring us on GitHub. Every contribution directly helps us create better tools for the WordPress ecosystem.
Requirements
You'll need to have ENVIRONMENTS and WP_ENV defined in your WordPress config.
The ENVIRONMENTS constant must be an array of 'environment' => 'url' elements:
$envs = [ 'development' => 'http://example.dev', 'staging' => 'http://staging.example.com', 'production' => 'http://example.com' ]; Config::define('ENVIRONMENTS', $envs);
WP_ENV must be defined as the current environment:
Config::define('WP_ENV', 'development');
If you use Bedrock, WP_ENV is already defined in the config.
Installation
This plugin must be installed via Composer. Add wp-stage-switcher to your project's dependencies:
composer require roots/wp-stage-switcher
Filters
bedrock/stage_switcher_colors
Customize the background colors for each environment in the admin bar menu. Returns an array of 'environment' => 'color' pairs.
Default colors:
[ 'development' => 'firebrick', 'staging' => 'chocolate', 'production' => 'transparent', ]
Example usage:
add_filter('bedrock/stage_switcher_colors', function ($colors) { return [ 'development' => '#dc2626', 'staging' => '#ea580c', 'production' => '#10b981', ]; });
bedrock/stage_switcher_visibility
Control who can see the stage switcher in the admin bar. Defaults to is_super_admin().
Example usage:
add_filter('bedrock/stage_switcher_visibility', function ($visible) { return current_user_can('manage_options'); });
Community
Keep track of development and community news.
- Join us on Discord by sponsoring us on GitHub
- Join us on Roots Discourse
- Follow @rootswp on Twitter
- Follow the Roots Blog
- Subscribe to the Roots Newsletter