A WordPress must-use plugin for easily switching between WP-palvelu.fi shadows
Install the plugin via Composer
composer require seravo/wp-palvelu-instance-switcher
Activate the plugin
wp plugin activate wp-palvelu-instance-switcher
You can also install the plugin by directly uploading the zip file as instructed below:
- Download the plugin
- Upload to the plugin to /wp-content/plugins/ via the WordPress plugin uploader or your preferred method
- Activate the plugin
Add these lines to your wp-config.php
/**
* WP-palvelu.fi Instance Switcher required configuration
*/
$wpis_siteurl = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTPS_DOMAIN_ALIAS');
if ( $wpis_siteurl )
define( 'COOKIEHASH', md5( $wpis_siteurl ) . getenv('CONTAINER') );
else
define( 'COOKIEHASH', '' );
To add instances, you have to define them in wp-config.php in the following way:
define( 'WPIS-PRODUCTION', '1234aa' );
define( 'WPIS-STAGING', '5678bb' );
define( 'WPIS-DEVELOPMENT', '9012cc' );
Use the "WPIS-" -prefix followed by the name of your instance to name the constants. Use the hash part of your container name to define the constant value. If the name of your container is "asdasd_123", use "123" to define the value.
You can insert your own admin notice for users that are in shadow
function my_shadow_admin_notice($admin_notice, $current_screen) {
return '<div class="notice notice-error"><p>This is staging. All content edited here will be lost. Return to production to create or edit content.</p></div>';
}
add_filter( 'wpp_instance_switcher_admin_notice', 'my_shadow_admin_notice', 10, 2 );