Skip to content

Instantly share code, notes, and snippets.

@dovy
Last active August 29, 2015 14:07
Show Gist options
  • Save dovy/4dd7abe5075b2e086a3f to your computer and use it in GitHub Desktop.
Save dovy/4dd7abe5075b2e086a3f to your computer and use it in GitHub Desktop.

This is a converter class for your php file. I was unclear if it was a standard plugin or a mu-plugin.

If it's a standard plugin, then you run it in a register_activation_hook( __FILE__, 'myplugin_activate' ); hook.

If it's not, then you need to set a variable and test for it. Something like surbma_data_migrated with just a boolean.

This is assuming that you're using Redux with surbma as your opt_name.

Also to filter the sections to add more values for each plugin, check the sample config. There's a class in there.

Happy birthday!

<?php
$new = array(
'pwp_google_analytics' => get_option( 'pwp_google_analytics' ),
'pwp_google_universal_analytics' => get_option( 'pwp_google_universal_analytics' ),
'pwp_google_universal_analytics_displayfeatures' => get_option( 'pwp_google_universal_analytics_displayfeatures' ),
);
$update = false;
foreach($new as $key => $value) {
if (!empty($true)) {
delete_option($key);
$update = true;
} else {
unset($new[$key]);
}
}
if ($update) {
$old_data = get_option('surbma');
$data = wp_parse_args($old_data, $new);
update_option('surbma', $data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment