
如果解决XAMPP无法正常运行问题
wp_get_environment_type ( No parameters )
wp_get_environment_type: 这个函数用来确定WordPress正在运行的环境类型。它可以返回四个可能的值中的一个。”production”,”staging”,”development”, or”local”。环境类型是通过检查几个环境变量的值来确定的,包括可以在wp-config.php文件中定义的WP_ENVIRONMENT_TYPE常数。
检索当前环境类型。
该类型可以通过`WP_ENVIRONMENT_TYPE`全局系统变量,或同名常量来设置。
可能的值是’local’, ‘development’, ‘staging’, and ‘production’。如果没有设置,该类型默认为”生产”。
function wp_get_environment_type() { static $current_env = ''; if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) { return $current_env; } $wp_environments = array( 'local', 'development', 'staging', 'production', ); // Add a note about the deprecated WP_ENVIRONMENT_TYPES constant. if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) { if ( function_exists( '__' ) ) { /* translators: %s: WP_ENVIRONMENT_TYPES */ $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' ); } else { $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' ); } _deprecated_argument( 'define()', '5.5.1', $message ); } // Check if the environment variable has been set, if `getenv` is available on the system. if ( function_exists( 'getenv' ) ) { $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); if ( false !== $has_env ) { $current_env = $has_env; } } // Fetch the environment from a constant, this overrides the global system variable. if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) { $current_env = WP_ENVIRONMENT_TYPE; } // Make sure the environment is an allowed one, and not accidentally set to an invalid value. if ( ! in_array( $current_env, $wp_environments, true ) ) { $current_env = 'production'; } return $current_env; }