NOTE: This is only applicable for legacy staging environments and their respective “live” WP Engine environments. For determining an environment name or environment by its type try the WP Engine API.
If your workflow includes writing code outside of WP Engine’s environment, and you need a way to differentiate between a WP Engine environment a legacy staging environment in your code you can use is_wpe()
.
is_wpe()
is a function that we have integrated into our platform to help you determine if you are running on a WP Engine environment.
- This function returns true
1
only if you are on the “live” WP Engine site (i.e. it is a WP Engine site, and it is not Legacy staging). - The output of this function is not boolean (e.g. is_wpe()===true will always return false) but instead is a numeric string (1 == true and 0 == false).
is_wpe_snapshot()
is a similar function that returns true 1
only if you are running on a WP Engine 1-click legacy staging environment.
When to use the is_wpe() function
If you are developing on a local environment and you want to test whether the site you’re seeing is on WP Engine or not, you can use something like the following within a test file in the root directory of your website:
<?php # Use WordPress functions outside of WordPress files define('WP_USE_THEMES', false); global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header; require('wp-load.php'); # Ensure the function exists before running it and printing out the return value. if (function_exists('is_wpe')) { echo is_wpe(); } else { echo "The function does not exist"; }
Visiting yourdomain.com/testfile.php
will then print one of the following:
1
if the site is running on a WP Engine production environment0
if it is not running on a WP Engine production environmentThe function does not exist
if theis_wpe()
function has not been defined in your environment (this should never be the case on a WP Engine server as long as our mu-plugin is installed).