
外掛標籤
開發者團隊
② 後台搜尋「StageBar – Staging Environment Indicator」→ 直接安裝(推薦)
原文外掛簡介
You have two tabs open that look identical. You make the change, you hit update, and only then do you glance at the address bar. Was that staging, or was that the live site?
StageBar answers that question before you start typing, not after. The WordPress admin bar changes colour and shows a badge, so where you are is the first thing you see on every screen:
LIVE – red
STAGING – amber
DEV – green
LOCAL – purple
Activate it and it works. There is nothing you have to configure first.
When it is not sure, it says LIVE
This is the idea the whole plugin is built around, and it is worth a minute of your time.
Telling you a staging site is LIVE is a nuisance. Telling you a live site is STAGING is the exact accident the plugin exists to prevent, because you would trust it and start making changes. So when it is not certain, it says LIVE.
That principle shows up in real decisions:
It matches whole parts of an address, never fragments. A genuine business at dev-shop.com.au or stage-lighting.com.au is shown as LIVE, because “dev” and “stage” there are part of a company name, not a signal.
It will not assume a whole hosting domain is staging. Managed hosts including WP Engine, Kinsta, Cloudways, Flywheel, Pressable and Elementor Hosting all serve real, live sites on their own domains before a custom domain is pointed at them. Their staging URLs are still recognised, because those contain a staging or dev part.
So if it says LIVE, treat it as live. If it says anything else, something specific told it so – and the settings screen will tell you exactly what.
When you need to correct it
Some staging sites do not look like staging sites from the outside. When that happens, go to Settings → StageBar and tell it about the site. Type an address, press Enter, and it becomes a tag you can remove again with a click.
You can be as broad or as precise as you like:
A full address such as staging.example.com matches that one site.
A domain such as example.com matches it and everything underneath it.
A single word such as uat matches any address using it as a name of its own, like uat.example.com.
The first list, Live, is there for the rarer case of a real site being labelled wrongly. Put that site’s full address in it and no other entry can override it.
If two of your entries could both apply to a site, the more exact one wins – a full address beats a domain, and a domain beats a single word – so being specific always does what you expect. The screen points out overlaps as you add them.
The settings screen explains itself
At the top it tells you which environment the site is on, the exact address it checked, and why it decided that – your own list, a built-in rule, or a setting in wp-config.php. No guessing about what the plugin is thinking.
You can also choose a colour for each environment, from five suggested shades or any hex value you like. The text colour is worked out from the background for you, so a badge can never end up unreadable. Each badge preview updates as you pick, and if you change the colour for the environment this site is currently in, the real admin bar at the top of the page updates with it – before you save anything.
What it does not do
Just as important as what it does:
It does not stop, block or slow down anything you do. It is a label, not a lock.
It does not change your content, your theme, or what visitors see. Logged-out visitors get nothing at all – not even a hidden marker in the page.
It never contacts an external server, for any reason.
It creates no database tables and stores nothing until you save the settings screen. Uninstalling removes the single row it may have created.
The most reliable setup, if you have access
Everything above is the plugin working out the answer for itself. If you can edit wp-config.php, you can simply tell WordPress the answer instead, and there is nothing left to guess:
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
This is a standard WordPress setting, not something this plugin invented, and other plugins understand it too. When it is set, StageBar uses it and ignores everything else.
For developers
Order of precedence: WP_ENVIRONMENT_TYPE, then your saved addresses, then the built-in rules, then production. Filters run last and override all of it.
stagebar_environment – override the resolved environment (local, development, staging, production). Any other value is ignored and treated as production.
stagebar_hostname_rules – add or change the built-in hostname patterns. An array of environment => array of PCRE patterns; unknown keys and non-string patterns are ignored.
stagebar_style – change the label or colours for an environment. Colours must be 3 or 6 digit hex strings including the leading #; anything else falls back to the resolved default.
stagebar_colour_admin_bar – return false to keep the default admin bar colour and show only the badge.
The plugin adds a stagebar-{environment} class to the
element in the admin, and on the front end when the admin bar is showing.Addresses you save are matched as plain text, never compiled as regular expressions, and every stored value is validated again each time it is read. The environment is worked out from home_url() – the site’s own recorded address – and never from the Host request header, which a proxy can rewrite.
Force the environment where you cannot edit wp-config.php:
add_filter( 'stagebar_environment', function () { return 'staging'; } );
Built and maintained by DeeperLook, a WordPress web design agency in Australia.
