Last active
December 12, 2015 09:58
-
-
Save gbaptista/4755251 to your computer and use it in GitHub Desktop.
Mudar o domínio base do Wordpress.
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
<?php | |
$mysql_host = 'localhost'; | |
$mysql_user = ''; | |
$mysql_pass = ''; | |
$mysql_base = 'wordpress_database'; | |
$old_domain = 'www.old_domain.com'; | |
$new_domain = 'www.new_domain.com'; | |
if($conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { | |
mysql_select_db($mysql_base, $conn); | |
} else { | |
echo mysql_error(); mysql_close($conn); exit; | |
} | |
$replaces = array( | |
'wp_comments' => array('comment_content'), | |
'wp_options' => array('option_value'), | |
'wp_postmeta' => array('meta_value'), | |
'wp_posts' => array('post_content', 'guid') | |
); | |
echo "\nMigrating $old_domain to $new_domain...\n"; | |
foreach ($replaces as $table => $columns) { | |
foreach ($columns as $column) { | |
echo "\n - Migrating {$table}[$column]...\n"; | |
mysql_query("UPDATE {$table} SET {$column}=REPLACE({$column}, '{$old_domain}', '{$new_domain}') WHERE {$column} LIKE '%$old_domain%'"); | |
} | |
} | |
echo "\nDone! [$old_domain to $new_domain] =)\n\n"; | |
mysql_close($conn); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment