PHPackages                             alleyinteractive/wp-environment-switcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alleyinteractive/wp-environment-switcher

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

alleyinteractive/wp-environment-switcher
========================================

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

v1.2.1(9mo ago)4119.0k↑15.4%[2 PRs](https://github.com/alleyinteractive/wp-environment-switcher/pulls)GPL-2.0-or-laterPHPPHP ^8.1CI passing

Since Jul 6Pushed 2mo ago18 watchersCompare

[ Source](https://github.com/alleyinteractive/wp-environment-switcher)[ Packagist](https://packagist.org/packages/alleyinteractive/wp-environment-switcher)[ Docs](https://github.com/alleyinteractive/wp-environment-switcher)[ RSS](/packages/alleyinteractive-wp-environment-switcher/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (10)Used By (0)

WordPress Environment Switcher
==============================

[](#wordpress-environment-switcher)

[![Playwright Tests](https://github.com/alleyinteractive/wp-environment-switcher/actions/workflows/playwright.yml/badge.svg)](https://github.com/alleyinteractive/wp-environment-switcher/actions/workflows/playwright.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
------------

[](#installation)

You can install the package via Composer:

```
composer require alleyinteractive/wp-environment-switcher
```

Usage
-----

[](#usage)

Activate the plugin in WordPress and you will see the switcher appear in the top right admin bar:

[![Screenshot of plugin](https://private-user-images.githubusercontent.com/346399/251573786-83684c99-4f74-4969-b302-a0c617c17190.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW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yMDI2MDMxN1QwNzE4MDFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hNzhkMjUzZjYyMDgwZGQyMGIzZWRiM2I5ZTcxY2E4ZWIxYTMxNTFmNmRjNDRhZGI2ZGQzOTEwZWE0Mjc2ZjM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Dj9iuJhcRnRo8MwpLzZyupGwgzPvtNzvJiXny69a0Uc)

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
-------

[](#testing)

Run `composer test` to run tests against PHPStan/PHPCS.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#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
-------

[](#license)

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

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance72

Regular maintenance activity

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~186 days

Total

5

Last Release

297d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/338d27065b1074f2d66d049d742f22996dd137eef6f91bc8f75350ceee1e8ef2?d=identicon)[srtfisher](/maintainers/srtfisher)

---

Top Contributors

[![srtfisher](https://avatars.githubusercontent.com/u/346399?v=4)](https://github.com/srtfisher "srtfisher (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

---

Tags

wordpresswordpress-pluginalleyinteractivewp-environment-switcher

### Embed Badge

![Health badge](/badges/alleyinteractive-wp-environment-switcher/health.svg)

```
[![Health](https://phpackages.com/badges/alleyinteractive-wp-environment-switcher/health.svg)](https://phpackages.com/packages/alleyinteractive-wp-environment-switcher)
```

###  Alternatives

[alleyinteractive/wp-block-converter

Convert HTML into Gutenberg Blocks with PHP

62321.0k1](/packages/alleyinteractive-wp-block-converter)[alleyinteractive/wp-curate

Plugin to curate homepages and other landing pages

10154.3k](/packages/alleyinteractive-wp-curate)[alleyinteractive/feed-consumer

Ingest external feeds and other data sources into WordPress

114.8k](/packages/alleyinteractive-feed-consumer)[nystudio107/richvariables

Allows you to easily use Craft Globals as variables in Rich Text fields

441.5k](/packages/nystudio107-richvariables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
