Created
October 12, 2010 08:04
-
-
Save scribu/621827 to your computer and use it in GitHub Desktop.
Copy entire sidebar configuration from one site to another
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 | |
/** | |
* Copy entire sidebar configuration from one site to another | |
* | |
* @param int $old_site The id of the original site | |
* @param int $old_site The id of the site to copy the widgets to | |
*/ | |
function copy_widgets($old_site, $new_site) { | |
global $wpdb, $blog_id; | |
$old_table = $wpdb->get_blog_prefix($old_site) . 'options'; | |
$new_table = $wpdb->get_blog_prefix($new_site) . 'options'; | |
$wpdb->query("DELETE FROM $new_table WHERE option_name LIKE 'widget_%'"); | |
$wpdb->query(" | |
INSERT INTO $new_table (option_name, option_value) | |
SELECT option_name, option_value FROM $old_table | |
WHERE option_name LIKE 'widget_%'; | |
"); | |
update_blog_option( $new_site, 'sidebars_widgets', | |
get_blog_option($old_site, 'sidebars_widgets') ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment