Version Description
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Go Live Update URLS |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.1
- go-live-update-urls.php +1 -1
- lib/GoLiveUpdateUrls.php +15 -9
- readme.txt +1 -1
go-live-update-urls.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://lipeimagination.info/
|
|
5 |
Description: This Plugin Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
|
6 |
Author: Mat Lipe
|
7 |
Author URI: http://lipeimagination/
|
8 |
-
Version: 2.2
|
9 |
*/
|
10 |
|
11 |
define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
5 |
Description: This Plugin Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
|
6 |
Author: Mat Lipe
|
7 |
Author URI: http://lipeimagination/
|
8 |
+
Version: 2.2.1
|
9 |
*/
|
10 |
|
11 |
define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
lib/GoLiveUpdateUrls.php
CHANGED
@@ -4,6 +4,9 @@
|
|
4 |
* @author Mat Lipe
|
5 |
* @since 2.2
|
6 |
*
|
|
|
|
|
|
|
7 |
* @TODO Cleanup the Names and formatting
|
8 |
*/
|
9 |
class GoLiveUpdateUrls{
|
@@ -209,6 +212,8 @@ function makeTheUpdates(){
|
|
209 |
*
|
210 |
* @param string $table the table to go through
|
211 |
* @param string $column to column in the table to go through
|
|
|
|
|
212 |
*
|
213 |
*/
|
214 |
function UpdateSeralizedTable( $table, $column = false ){
|
@@ -218,19 +223,18 @@ function makeTheUpdates(){
|
|
218 |
|
219 |
//Get all the Seralized Rows and Replace them properly
|
220 |
$rows = $wpdb->get_results("SELECT $primary_key_column, $column FROM $table WHERE $column LIKE 'a:%' OR $column LIKE 'O:%'");
|
221 |
-
|
222 |
foreach( $rows as $row ){
|
223 |
-
|
|
|
224 |
|
225 |
$clean = $this->replaceTree($data, $this->oldurl, $this->newurl);
|
226 |
//If we switch to a submain we have to run this again to remove the doubles
|
227 |
if( $this->double_subdomain ){
|
228 |
$clean = $this->replaceTree($clean, $this->double_subdomain, $this->newurl);
|
229 |
}
|
230 |
-
|
231 |
-
|
232 |
-
$wpdb->query("UPDATE $table SET $column='".serialize($clean)."' WHERE $primary_key_column='".$row->{$primary_key_column}."'");
|
233 |
-
|
234 |
}
|
235 |
}
|
236 |
|
@@ -247,14 +251,16 @@ function makeTheUpdates(){
|
|
247 |
* @param string $new the new string
|
248 |
* @param bool [optional] $changeKeys to replace string in keys as well - defaults to false
|
249 |
*
|
|
|
|
|
250 |
*/
|
251 |
function replaceTree( $data, $old, $new, $changeKeys = false ){
|
252 |
|
253 |
if( is_string($data) ){
|
254 |
-
return str_replace( $old, $new, $data );
|
255 |
}
|
256 |
|
257 |
-
if( !
|
258 |
return $data;
|
259 |
}
|
260 |
|
@@ -265,7 +271,7 @@ function makeTheUpdates(){
|
|
265 |
$key = str_replace( $old, $new, $key );
|
266 |
}
|
267 |
|
268 |
-
if( $
|
269 |
$data[$key] = $this->replaceTree($item, $old, $new);
|
270 |
} else {
|
271 |
$data->{$key} = $this->replaceTree($item, $old, $new);
|
4 |
* @author Mat Lipe
|
5 |
* @since 2.2
|
6 |
*
|
7 |
+
*
|
8 |
+
* @updated 3.26.13
|
9 |
+
*
|
10 |
* @TODO Cleanup the Names and formatting
|
11 |
*/
|
12 |
class GoLiveUpdateUrls{
|
212 |
*
|
213 |
* @param string $table the table to go through
|
214 |
* @param string $column to column in the table to go through
|
215 |
+
*
|
216 |
+
* @since 3.26.13
|
217 |
*
|
218 |
*/
|
219 |
function UpdateSeralizedTable( $table, $column = false ){
|
223 |
|
224 |
//Get all the Seralized Rows and Replace them properly
|
225 |
$rows = $wpdb->get_results("SELECT $primary_key_column, $column FROM $table WHERE $column LIKE 'a:%' OR $column LIKE 'O:%'");
|
226 |
+
|
227 |
foreach( $rows as $row ){
|
228 |
+
$data = @unserialize($row->{$column});
|
229 |
+
if( $data === 'b:0' || $data === false ) continue;
|
230 |
|
231 |
$clean = $this->replaceTree($data, $this->oldurl, $this->newurl);
|
232 |
//If we switch to a submain we have to run this again to remove the doubles
|
233 |
if( $this->double_subdomain ){
|
234 |
$clean = $this->replaceTree($clean, $this->double_subdomain, $this->newurl);
|
235 |
}
|
236 |
+
|
237 |
+
$wpdb->query($wpdb->prepare( "UPDATE $table SET $column= %s WHERE $primary_key_column= %s ", serialize($clean), $row->{$primary_key_column} ) );
|
|
|
|
|
238 |
}
|
239 |
}
|
240 |
|
251 |
* @param string $new the new string
|
252 |
* @param bool [optional] $changeKeys to replace string in keys as well - defaults to false
|
253 |
*
|
254 |
+
* @since 3.26.13
|
255 |
+
*
|
256 |
*/
|
257 |
function replaceTree( $data, $old, $new, $changeKeys = false ){
|
258 |
|
259 |
if( is_string($data) ){
|
260 |
+
return trim(str_replace( $old, $new, $data ));
|
261 |
}
|
262 |
|
263 |
+
if( !is_array( $data) && !is_object($data) ){
|
264 |
return $data;
|
265 |
}
|
266 |
|
271 |
$key = str_replace( $old, $new, $key );
|
272 |
}
|
273 |
|
274 |
+
if( is_array( $data) ){
|
275 |
$data[$key] = $this->replaceTree($item, $old, $new);
|
276 |
} else {
|
277 |
$data->{$key} = $this->replaceTree($item, $old, $new);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
|
|
4 |
Tags: Go Live, Urls, Domain Changes
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 2.2
|
8 |
|
9 |
== Description ==
|
10 |
|
4 |
Tags: Go Live, Urls, Domain Changes
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 2.2.1
|
8 |
|
9 |
== Description ==
|
10 |
|