最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - wp_get_environment_type is undefined

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论