Guest User

Untitled

a guest
Jun 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Copy entire sidebar configuration from one site to another
  5. *
  6. * @param int $old_site The id of the original site
  7. * @param int $old_site The id of the site to copy the widgets to
  8. */
  9. function copy_widgets($old_site, $new_site) {
  10. global $wpdb, $blog_id;
  11.  
  12. $old_table = $wpdb->get_blog_prefix($old_site) . 'options';
  13. $new_table = $wpdb->get_blog_prefix($new_site) . 'options';
  14. $wpdb->query("DELETE FROM $new_table WHERE option_name LIKE 'widget_%'");
  15.  
  16. $wpdb->query("
  17. INSERT INTO $new_table (option_name, option_value)
  18. SELECT option_name, option_value FROM $old_table
  19. WHERE option_name LIKE 'widget_%';
  20. ");
  21.  
  22. update_blog_option( $new_site, 'sidebars_widgets',
  23. get_blog_option($old_site, 'sidebars_widgets') );
  24. }
Add Comment
Please, Sign In to add comment