Created
January 29, 2016 08:43
-
-
Save pniaps/3ab8b79476ef25982d42 to your computer and use it in GitHub Desktop.
Replace domain in wordpress configuration
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
//Insert here serialized string from wp_options table | |
$str = ''; | |
function change(&$data) | |
{ | |
if(is_string($data) && json_decode($data)){ | |
$json = json_decode($data); | |
if(is_array($json) || is_object($json)){ | |
foreach($json as &$jsonvalue){ | |
change($jsonvalue); | |
} | |
$data = json_encode($json); | |
} | |
return; | |
}else if(is_array($data) || is_object($data)){ | |
foreach($data as &$value){ | |
change($value); | |
} | |
return; | |
} | |
if(is_string($data)){ | |
//Set here old string to replace | |
$old = 'oldomain.tld/subdir' | |
//Set here new string | |
$new = 'newdomain.tld' | |
$data = str_replace($old, $new, $data); | |
} | |
} | |
foreach($code as &$value){ | |
change($value); | |
} | |
header("Content-Type: text/plain"); | |
echo serialize($code); | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment