equal
deleted
inserted
replaced
1 <?php |
1 <?php |
2 /* |
2 /* |
3 Plugin Name: Blog Copier |
3 Plugin Name: Blog Copier |
4 Plugin URI: http://wordpress.org/extend/plugins/blog-copier/ |
4 Plugin URI: http://wordpress.org/extend/plugins/blog-copier/ |
5 Description: Enables superusers to copy existing sub blogs to new sub blogs. |
5 Description: Enables superusers to copy existing sub blogs to new sub blogs. |
6 Version: 1.0.5 |
6 Version: 1.0.7 |
7 Author: Modern Tribe, Inc. |
7 Author: Modern Tribe, Inc. |
8 Network: true |
8 Network: true |
9 Author URI: http://tri.be |
9 Author URI: http://tri.be |
10 |
10 |
11 Copyright: (C) 2012 Modern Tribe derived from (C) 2010 Ron Rennick, All rights reserved. |
11 Copyright: (C) 2014 Modern Tribe derived from (C) 2010 Ron Rennick, All rights reserved. |
12 |
12 |
13 See http://wpebooks.com/replicator/ for original code. |
13 See http://wpebooks.com/replicator/ for original code. |
14 |
14 |
15 This program is free software; you can redistribute it and/or modify |
15 This program is free software; you can redistribute it and/or modify |
16 it under the terms of the GNU General Public License as published by |
16 it under the terms of the GNU General Public License as published by |
249 $this->replace_content_urls( $from_blog_id, $to_blog_id ); |
249 $this->replace_content_urls( $from_blog_id, $to_blog_id ); |
250 |
250 |
251 } |
251 } |
252 $msg = sprintf(__( 'Copied: %s in %s seconds', $this->_domain ),'<a href="http://'.$newdomain.'" target="_blank">'.$title.'</a>', number_format_i18n(timer_stop())); |
252 $msg = sprintf(__( 'Copied: %s in %s seconds', $this->_domain ),'<a href="http://'.$newdomain.'" target="_blank">'.$title.'</a>', number_format_i18n(timer_stop())); |
253 do_action( 'log', __( 'Copy Complete!', $this->_domain ), $this->_domain, $msg ); |
253 do_action( 'log', __( 'Copy Complete!', $this->_domain ), $this->_domain, $msg ); |
|
254 do_action( 'copy_blog_complete', $from_blog_id, $to_blog_id ); |
254 } |
255 } |
255 } else { |
256 } else { |
256 $msg = $to_blog_id->get_error_message(); |
257 $msg = $to_blog_id->get_error_message(); |
257 } |
258 } |
258 return $msg; |
259 return $msg; |
309 $query = "INSERT {$newtable} SELECT * FROM {$table}"; |
310 $query = "INSERT {$newtable} SELECT * FROM {$table}"; |
310 do_action( 'log', $query, $this->_domain); |
311 do_action( 'log', $query, $this->_domain); |
311 $wpdb->get_results($query); |
312 $wpdb->get_results($query); |
312 } |
313 } |
313 |
314 |
314 // apply key opptions from new blog. |
|
315 switch_to_blog( $to_blog_id ); |
315 switch_to_blog( $to_blog_id ); |
|
316 |
|
317 // caches will be incorrect after direct DB copies |
|
318 wp_cache_delete( 'notoptions', 'options' ); |
|
319 wp_cache_delete( 'alloptions', 'options' ); |
|
320 |
|
321 // apply key options from new blog. |
316 foreach( $saved_options as $option_name => $option_value ) { |
322 foreach( $saved_options as $option_name => $option_value ) { |
317 update_option( $option_name, $option_value ); |
323 update_option( $option_name, $option_value ); |
318 } |
324 } |
319 |
325 |
320 /// fix all options with the wrong prefix... |
326 /// fix all options with the wrong prefix... |
324 if( $options ) { |
330 if( $options ) { |
325 foreach( $options as $option ) { |
331 foreach( $options as $option ) { |
326 $raw_option_name = substr($option->option_name,$from_blog_prefix_length); |
332 $raw_option_name = substr($option->option_name,$from_blog_prefix_length); |
327 $wpdb->update( $wpdb->options, array( 'option_name' => $to_blog_prefix . $raw_option_name ), array( 'option_id' => $option->option_id ) ); |
333 $wpdb->update( $wpdb->options, array( 'option_name' => $to_blog_prefix . $raw_option_name ), array( 'option_id' => $option->option_id ) ); |
328 } |
334 } |
329 wp_cache_flush(); |
335 |
|
336 // caches will be incorrect after direct DB copies |
|
337 wp_cache_delete( 'notoptions', 'options' ); |
|
338 wp_cache_delete( 'alloptions', 'options' ); |
330 } |
339 } |
331 |
340 |
332 // Fix GUIDs on copied posts |
341 // Fix GUIDs on copied posts |
333 $this->replace_guid_urls( $from_blog_id, $to_blog_id ); |
342 $this->replace_guid_urls( $from_blog_id, $to_blog_id ); |
334 |
343 |