Enhance domain replacement process in wp-import.php with error handling and informative output
This commit is contained in:
+13
-1
@@ -14,7 +14,19 @@ echo shell_exec( 'wp db import ./wp-content/mysql.sql' );
|
||||
|
||||
$domain = shell_exec( 'wp option get siteurl' );
|
||||
$search_replace = trim( $domain ) . ' ' . trim( $staging_domain );
|
||||
echo shell_exec( "wp search-replace $search_replace --all-tables" );
|
||||
|
||||
// Replace the domain in the database.
|
||||
echo "--------------------------------";
|
||||
echo "Performing search and replace:";
|
||||
echo "wp search-replace $search_replace --all-tables";
|
||||
echo "--------------------------------";
|
||||
|
||||
try {
|
||||
echo shell_exec( "wp search-replace $search_replace --all-tables" );
|
||||
} catch ( Exception $e ) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
rmdir( './wp-content/plugins/post-smtp' );
|
||||
rmdir( './wp-content/plugins/wordfence' );
|
||||
|
||||
Reference in New Issue
Block a user