PHP code example of alleyinteractive / wp-environment-switcher
1. Go to this page and download the library: Download alleyinteractive/wp-environment-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/ */
alleyinteractive / wp-environment-switcher example snippets
add_filter(
'wp_environment_switcher_current_environment',
fn () => 'my-custom-environment'
);
add_filter(
'wp_environment_switcher_environments',
fn () => [
'production' => 'https://example.org',
'staging' => 'https://staging.example.org',
'local' => 'https://example.test',
]
);
add_filter(
'wp_environment_switcher_environments',
fn () => [
[
'type' => 'production',
'url' => 'https://example.org',
'label' => 'Production Site',
],
[
'type' => 'staging',
'url' => 'https://staging.example.org',
'label' => 'Staging Site',
],
[
'type' => 'local',
'url' => 'https://example.test',
'label' => 'Local Development',
],
]
);