Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Last active October 27, 2020 04:34
Show Gist options
  • Save daltonrooney/470619cca87a6c29cb84f92d856b9ec1 to your computer and use it in GitHub Desktop.
Save daltonrooney/470619cca87a6c29cb84f92d856b9ec1 to your computer and use it in GitHub Desktop.
Prevent ACF Pro license key from being overwritten during WP Migrate DB Pro migration
<?php
/*
Based on http://github.com/deliciousbrains/wp-migrate-db-pro-tweaks
*/
class ACF_WP_Migrate_DB_Pro_Tweaks {
function __construct() {
add_filter( 'wpmdb_preserved_options', array( $this, 'preserved_options' ) );
}
/**
* By default, 'wpmdb_settings' and 'wpmdb_error_log' are preserved when the database is overwritten in a migration.
* This filter allows you to define additional options (from wp_options) to preserve during a migration.
* The example below preserves the 'blogname' value though any number of additional options may be added.
*/
function preserved_options( $options ) {
$options[] = 'acf_pro_license';
return $options;
}
}
new ACF_WP_Migrate_DB_Pro_Tweaks();
@araphiel
Copy link

Thanks for this.

@jackfearing
Copy link

jackfearing commented Aug 16, 2017

This may be a stupid question but where do you place the code? I've tired placing it in my functions.php file but it doesn't seem to work. I'm also assuming I don't need to add my license to the $options value but just wanted to double check.

@jackfearing
Copy link

Issue resolved. I realized I needed to have the code on both the local and production sites for it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment