PHP code example of roots / wp-stage-switcher

1. Go to this page and download the library: Download roots/wp-stage-switcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

roots / wp-stage-switcher example snippets


$envs = [
  'development' => 'http://example.dev',
  'staging'     => 'http://staging.example.com',
  'production'  => 'http://example.com'
];
Config::define('ENVIRONMENTS', $envs);

Config::define('WP_ENV', 'development');

[
  'development' => 'firebrick',
  'staging'     => 'chocolate',
  'production'  => 'transparent',
]

add_filter('bedrock/stage_switcher_colors', function ($colors) {
  return [
    'development' => '#dc2626',
    'staging'     => '#ea580c',
    'production'  => '#10b981',
  ];
});

add_filter('bedrock/stage_switcher_visibility', function ($visible) {
  return current_user_can('manage_options');
});