Setting up environment in wordpress

Setting up environment in wordpress

December 5th, 2020 admin 245 Views 0 Uncategorised57 seconds

In wordpress new function this environment function added from 5.5. In this tutorial we can learn how to use this. By default this wp environment has following values that is production, local, development and staging.

The environment needs to be set up in the wp-config.php file. Like the below example in that we have used production you can change according to the environment you are going to setup.

define( 'WP_ENVIRONMENT_TYPE', 'staging' );
How to use it in your plugin or theme ?

Below is the example for using that.

switch ( wp_get_environment_type() ) {
    case 'local':
    case 'development':
        do_nothing();
        break;
      
    case 'staging':
        do_staging_thing();
        break;
      
    case 'production':
    default:
        do_production_thing();
        break;
}

About The Author

admin

Leave Your Thoughts Here...
Notice: Undefined variable: comment in /home/letshmvm/public_html/wp-content/themes/shabu-portfolio/functions.php on line 557

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.

Name *
Comment

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy.