WP Manifestindependent plugin directory
manifest / developer / wp-environment-switcher

WordPress Environment Switcher WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Easily switch between hosting environments in WordPress.

★ 4stars
304kcomposer installs
v1.2.1latest · 1 year ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/alleyinteractive/wp-environment-switcher/archive/refs/heads/develop.zip

On Packagist as alleyinteractive/wp-environment-switcher:

composer require alleyinteractive/wp-environment-switcher
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Easily switch between different site environments from the WordPress admin bar.

Props to WordPress Stage Switcher for the inspiration.

Installation

You can install the package via Composer:

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:

Screenshot of plugin

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:

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:

add_filter(
    'wp_environment_switcher_environments',
    fn () => [
        'production' => 'https://example.org',
        'staging'    => 'https://staging.example.org',
        'local'      => 'https://example.test',
    ]
);

The environments can also be defined as an array of associative arrays, which allows for more flexibility:

add_filter(
    'wp_environment_switcher_environments',
    fn () => [
        [
            'type'  => 'production',
            'url'   => 'https://example.org',
            'label' => 'Production Site',
        ],
        [
            'type'  => 'staging',
            'url'   => 'https://staging.example.org',
            'label' => 'Staging Site',
        ],
        [
            'type'  => 'local',
            'url'   => 'https://example.test',
            'label' => 'Local Development',
        ],
    ]
);

The type, url, and label keys are required for each environment.

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 for more information on what has changed recently.

Credits

This project is actively maintained by Alley Interactive. Like what you see? Come work with us.

License

The GNU General Public License (GPL) license. Please see License File for more information.

Releases

5 releases.

Tag
Published
v1.2.1 latest
Jul 25, 2025 1 year ago
Jul 2, 2025 1 year ago
Jul 3, 2024 2 years ago
Jul 20, 2023 3 years ago
Jul 10, 2023 3 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

WordPress Environment Switcher 1.2.1 · audited by WP Registry

No security issues found.

Audited release
1.2.1
Findings
none
Worst severity
—
Content hash
91a4c63117410c1e40ebc1e4…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.