Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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') );
- }
Add Comment
Please, Sign In to add comment