I don’t understand wordpress, why is this wp_get_environment_type function undefined?
Isn’t this a “native” wordpress function? How can I make it defined? Here is my code inside of a MU-Plugin file:
add_action('admin_init', function() {
$environment = wp_get_environment_type();
//...
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
It is a core WP function, but only after WordPress version 5.5.0.
If you’re using an older version of WordPress, it won’t exist yet.
Do this:
add_action('admin_init', function() {
if ( ! function_exists( 'wp_get_environment_type' ) ) {
return;
}
$environment = wp_get_environment_type();
//...
Or, better still, make sure your WordPress installation is up to date.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
