You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Always use WP-compatible value in WP_ENVIRONMENT_TYPE
Defaulting to production in case can't be custom value can't be mapped.
Also:
- ensure WP_ENV is always defined
- when mapping custom env to WP, check non-word characters, e.g. "mydev" won't map to "development", "my-dev" will.
Copy file name to clipboardExpand all lines: docs/03-WordPress-Integration.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,11 +147,11 @@ WordPress does not allow arbitrary values for `WP_ENVIRONMENT_TYPE`, in fact it
147
147
-`"staging"`
148
148
-`"production"`
149
149
150
-
Unlike WordPress, WP Starter does not limit `WP_ENVIRONMENT_TYPE` (`WP_ENV` / `WORDPRESS_ENV`) to specific values, and in the case a valuenon supported by WordPress is used, to maximize compatibility, WP Starter will try to "map" different values to one of those supported by WP.
150
+
Unlike WordPress, WP Starter does not limit environment to specific values, and in the case a value not supported by WordPress is used, to maximize compatibility, WP Starter will try to "map" different values to one of those supported by WP.
151
151
152
-
For example, setting `WP_ENVIRONMENT_TYPE` to `"develop"` WP Starter will define a `WP_ENVIRONMENT_TYPE` constant having `"development"` as value.
152
+
For example, setting `WP_ENVIRONMENT_TYPE`env variable to `"develop"` WP Starter will define a `WP_ENVIRONMENT_TYPE` constant having `"development"` as value.
153
153
154
-
The original `"develop"` value will be available in a constant named `WP_ENV`.
154
+
The original `"develop"` value will be available in the `WP_ENV` constant.
155
155
156
156
In the case WP Starter is not able to map an environment to a value supported by WordPress, the original value will be available in both `WP_ENVIRONMENT_TYPE` and `WP_ENV`, but the WordPress [`wp_get_environment_type`](https://developer.wordpress.org/reference/functions/wp_get_environment_type/) function will return `"production"` because that is te default value used by WordPress.
WP Starter was not able to map `"something_very_custom"` to any of the four environment types supported by WordPress, so stored it as-is in `WP_ENVIRONMENT_TYPE` constant.
206
+
WP Starter was not able to map `"something_very_custom"` to any of the four environment types supported by WordPress, so stored "production" in `WP_ENVIRONMENT_TYPE` constant, because in any case WordPress would have defaulted to that value when calling `wp_get_environment_type()`.
207
207
208
-
However, because `"something_very_custom"` is not a value supported by WordPress `wp_get_environment_type()` will return `"production"`.
209
-
210
-
This is why we suggest referring to the constant `WP_ENVIRONMENT_TYPE` instead to the function `wp_get_environment_type()` when there's the desire (or the need) to use environment types that are not one the four supported by WordPress.
208
+
This is why we suggest referring to the constant `WP_ENV` instead to the `WP_ENVIRONMENT_TYPE` constant or the function `wp_get_environment_type()` when there's the desire (or the need) to use environment types that are not one the four supported by WordPress.
211
209
212
210
Finally, it must be noted that is possible to use a custom WP Starter-specific environment and a WordPress compatible environment by setting _both_`WP_ENV` and `WP_ENVIRONMENT_TYPE`.
0 commit comments