Last active
August 29, 2015 14:14
-
-
Save polevaultweb/d0d27fda7eda47d9f87e to your computer and use it in GitHub Desktop.
Edit profile IDs for WP Migrate DB Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'admin_init', 'wpmdb_tweak_profile_id_edit' ); | |
function wpmdb_tweak_profile_id_edit() { | |
$profile_mappings = array( | |
2 => 1, | |
3 => 2, | |
); | |
$wpmdb_settings = get_site_option( 'wpmdb_settings' ); | |
$old_profiles = $wpmdb_settings['profiles']; | |
if ( isset( $old_profiles[0] ) ) { | |
// already been run, abort | |
return; | |
} | |
$new_profiles = array(); | |
foreach ( $old_profiles as $key => $profile ) { | |
$id = $key + 1; // the profile ID is always +1 to array key | |
if ( isset( $profile_mappings[ $id ] ) ) { | |
$key = $profile_mappings[ $id ] - 1; | |
} | |
$new_profiles[$key] = $profile; | |
} | |
$wpmdb_settings['profiles'] = $new_profiles; | |
update_site_option( 'wpmdb_settings', $wpmdb_settings ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment