Skip to content

Instantly share code, notes, and snippets.

Last active November 7, 2018 00:25
Show Gist options
  • Save webaware/6959279 to your computer and use it in GitHub Desktop.
Save webaware/6959279 to your computer and use it in GitHub Desktop.
Preserve some WordPress test/dev environment settings when pulling data from a production server with WP Migrate DB Pro
Plugin Name: WP Migrate DB Fix Options
Plugin URI:
Description: Fix some options after a WP Migrate DB Pro migration, back to dev/test mode
Version: 1.0.0
Author: WebAware
Author URI:
* tell WP Migrate DB Pro to preserve some options, so that we can stay in dev / test mode
* @param string $preserved_options
* @return string
add_filter('wpmdb_preserved_options', function($preserved_options) {
$preserved_options = array_merge($preserved_options, array(
'active_plugins', // don't clobber dev/test plugins!
'admin_email', // don't send test emails to client!
'blog_public', // don't tell Google it can index test site!
return array_unique($preserved_options);
* after WP Migrate DB Pro migration
* @param string $type
* @param string $location
add_action('wpmdb_migration_complete', function($type, $location) {
// only for Pull migrations from another server
if ($type == 'pull') {
// force refresh of options
// WooCommerce eWAY settings
$settings = get_option('woocommerce_eway_payments_settings');
if (is_array($settings)) {
$settings['eway_customerid'] = '87654321';
$settings['eway_sandbox'] = 'yes';
update_option('woocommerce_eway_payments_settings', $settings);
// WooCommerce email settings
$settings = get_option('woocommerce_new_order_settings');
if (is_array($settings)) {
$settings['recipient'] = '';
update_option('woocommerce_new_order_settings', $settings);
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment