Linux 软件免费装
Banner图

Webknit Environment Indicator

开发者 webknitdigital
更新时间 2026年10月30日 17:04
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

development badge environment staging indicator

下载

1.0.0

详情介绍:

Webknit Environment Indicator puts a clear, colored badge on every copy of your site that isn't production: How the environment is decided
  1. The environment you choose on the settings page for this site URL.
  2. Otherwise, WordPress's own WP_ENVIRONMENT_TYPE setting.
  3. Otherwise, Local if the site runs on a local-only address: localhost, 127.0.0.1, or a domain ending in .local, .test, .localhost, .example or .invalid.
  4. Otherwise, production (no badge).
Developers can override the result with the webknit_environment_indicator_environment filter. Settings are saved per site URL When you clone a site, its database (and this plugin's settings) goes with it. To stop a "Staging" setting from ending up on your live site after a push to production, settings are stored separately for each site URL. Settings saved for a different URL are never applied; the settings page shows a URL mismatch warning and asks you to configure the site again.

安装:

  1. Upload the plugin files to /wp-content/plugins/webknit-environment-indicator, or install through the WordPress plugins screen directly.
  2. Activate the plugin through the "Plugins" screen in WordPress.
  3. Go to Settings → Environment Indicator and choose the environment for this site, or define WP_ENVIRONMENT_TYPE in wp-config.php.

屏幕截图:

  • Settings page: the environment for this site URL, where the badge shows, the wp-admin and front-end badge positions, and the label and color for each environment.
  • The front-end badge, shown to visitors who aren't logged in too, since staging links are often shared with clients.

常见问题:

Why doesn't it guess "staging" from my site's address?

Guessing from names like staging. or dev., or from the .dev domain, can be wrong, and a wrong guess would put a "Staging" badge on a live site. That's exactly the mistake this plugin exists to prevent, so it only acts on addresses that can never be a public site (such as localhost, .local and .test). For everything else, choose the environment in the settings or set WP_ENVIRONMENT_TYPE.

I copied my site and the settings page says "URL mismatch".

The settings in the database were saved on a different site URL, so they are not applied here. Choose the environment for this URL and save. Settings left behind for other URLs are never used here, and are deleted if you uninstall the plugin.

Can I hide the front-end badge from visitors?

Yes. Set "Show badge on front end" to No. The badge still shows in wp-admin and on the login page.

How do I set the environment in code?

Define it in wp-config.php: define( 'WP_ENVIRONMENT_TYPE', 'staging' ); Or use the filter: add_filter( 'webknit_environment_indicator_environment', function () { return 'staging'; } );

Does it stop search engines indexing my staging site?

No, it warns you. If the site isn't production and "Discourage search engines from indexing this site" (Settings → Reading) is off, you'll see a warning on the plugin's settings page and on the Dashboard, Plugins and Reading screens. It also warns the other way round: when the site is set as production but search engines are discouraged, which often happens after a staging site is pushed live. The plugin never changes that setting itself. For real protection, put staging sites behind a password.

Is this an official WordPress feature?

No. It's a Webknit Digital plugin that reads WordPress's own WP_ENVIRONMENT_TYPE setting when you have one.

更新日志:

1.0.0