Automattic / vip-go-wpcom-compat

VIP Go / WordPress.com Compatibility
https://wpvip.com
2 stars 6 forks source link

Add CLI command to import theme-related options. #7

Closed vaurdan closed 5 years ago

vaurdan commented 6 years ago

When importing from WordPress.com, we need to reactivate the theme, and since the theme slug is different between WordPress.com and VIP Go, every menu assignment, widget assignment, and theme-related settings are lost. This happens because in WordPress.com all the VIP themes are prefixed with vip/.

This command allows to import these options from a JSON file. The JSON file is generated in a WordPress.com sandbox, with the command wp vip-export theme-options.

This was originally on PR #862 of Automattic/vip-go-mu-plugins.

joshbetz commented 6 years ago

This command allows to import these options from a JSON file.

Can we migrate the old theme options by fixing the slug in the existing options?

emrikol commented 6 years ago

This command allows to import these options from a JSON file.

Can we migrate the old theme options by fixing the slug in the existing options?

We should be able to with:

UPDATE wp_options SET option_name = REPLACE( option_name, 'vip/', '') WHERE option_name LIKE 'theme_mods_vip/%';
UPDATE wp_options SET option_value = REPLACE( option_value, 'vip/', '') WHERE option_name = 'template';
UPDATE wp_options SET option_value = REPLACE( option_value, 'vip/', '') WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = REPLACE( option_value, 'premium/', '') WHERE option_name = 'template';
UPDATE wp_options SET option_value = REPLACE( option_value, 'premium/', '') WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_name = REPLACE( option_name, 'premium/', '') WHERE option_name LIKE 'theme_mods_premium/%';
UPDATE wp_options SET option_name = REPLACE( option_name, 'pub/', '') WHERE option_name LIKE 'theme_mods_pub/%';
UPDATE wp_options SET option_value = REPLACE( option_value, 'pub/', '') WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = REPLACE( option_value, 'pub/', '') WHERE option_name = 'template';
joshbetz commented 6 years ago

I think we should close this. I'm going to include the SQL @emrikol mentioned in the migration tools. Thoughts?