An open API service indexing awesome lists of open source software.

https://github.com/davekellam/dont-mess-up-prod

A WordPress plugin that provides an admin bar prod to remind you what environment you're currently working in
https://github.com/davekellam/dont-mess-up-prod

admin-bar environment wordpress wordpress-plugin

Last synced: 5 months ago
JSON representation

A WordPress plugin that provides an admin bar prod to remind you what environment you're currently working in

Awesome Lists containing this project

README

          

# Don't Mess Up Prod

This plugin displays a colored environment indicator in the WordPress admin bar to help developers and content managers identify which environment they're working in.

![Environment indicator screenshot](.wordpress-org/screenshot-1.png)

See a [live preview on Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/davekellam/dont-mess-up-prod/main/.wordpress-org/blueprints/blueprint.json).

## Installation

### Manual

1. Upload the plugin files to `/wp-content/plugins/dont-mess-up-prod/`
2. Activate the plugin through the "Plugins" screen in WordPress
3. Configure the plugin via the Settings → Don’t Mess Up Prod screen (or filters)

### Composer

```bash
composer require davekellam/dont-mess-up-prod
```

## Environment Detection

The plugin detects the current environment using this priority order:

1. **URL matching** – Compares the current site URL against the configured environment URLs. This list will also be used to generate a list of links that appears on hover in the admin bar.
2. **`wp_get_environment_type()`** – Which defaults to `production` and can be set via php constant:

```php
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
```

The indicator is visible to users who either meet the minimum capability (defaults to `publish_posts`, filterable via `dmup_minimum_capability`) or whose username appears in the allowed users filter. This keeps visibility limited to the folks who need the context.

## Configuration

The plugin can be configured using the WordPress admin screen or using filters.

### Admin Settings

Go to **Settings → Don’t Mess Up Prod** to configure:

- **Colors** for each environment (local, development, staging, production)
- **URLs** for each environment (used for detection and quick links)

Settings are saved per environment, and defaults are provided out of the box.

### Example Configuration (mu-plugin)

Create a file `/wp-content/mu-plugins/dmup-config.php`:

```php
'http://yourproject.local',
'development' => 'https://dev.yourproject.com',
'staging' => 'https://staging.yourproject.com',
'production' => 'https://yourproject.com',
];
}
add_filter( 'dmup_environment_urls', 'dmup_set_environment_urls' );

/**
* Configure environment colors for your project
*
* Customize the colors used for each environment
*
* @param array $colors Current environment colors array.
* @return array Modified environment colors array.
*/
function dmup_set_environment_colors( $colors ) {
return [
'local' => '#17a2b8', // blue
'development' => '#6f42c1', // purple
'staging' => '#ffc107', // yellow
'production' => '#dc3545', // red
];
}
// Note: Admin settings are applied at priority 20.
// If you want to override admin settings in code, use a higher priority.
add_filter( 'dmup_environment_colors', 'dmup_set_environment_colors', 30 );
```

## License

GPL-2.0-or-later