admin管理员组

文章数量:1307509

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();
//...

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();
//...
Share Improve this question asked Jan 18, 2021 at 21:04 now_worldnow_world 1155 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 5

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.

本文标签: pluginswpgetenvironmenttype is undefined