Skip to main content

benecaster_is_production_site()

Utilities Free
benecaster_is_production_site(): bool

Whether this install is the real production site. Check it before anything that reaches a real person or a live outside service: a copy keeps its cached add-on grants and stored secrets, so nothing else stops it. See Keep staging test data out of your production CRM and email lists.

Return Value

Type: bool

false for a clone at an ordinary hostname, for an install at a staging hostname and for one with BENECASTER_STAGING set. true otherwise, and always true when BENECASTER_IS_PRODUCTION is set.

Example

if ( ! benecaster_is_production_site() ) {
    return; // Don't push test subscribers to the production CRM.
}

Notes

BENECASTER_IS_PRODUCTION makes it true on any install, including a copy whose wp-config.php came with it. An install that has not recorded its address yet, which happens on its first admin page load, also reads as production.

There is deliberately no filter. The constant is the way out for a site this gets wrong, and a filter would let any plugin talk a copy into contacting real people.

It reads options only, so it is safe on a front-end request and needs no caching by the caller. Ask at send time as well as at queue time if a job can outlive the request.

Need this built rather than just documented? See our services →