Enhance domain replacement process in wp-import.php with error handling and informative output
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
.idea
|
||||||
|
.vscode
|
||||||
@@ -14,7 +14,19 @@ echo shell_exec( 'wp db import ./wp-content/mysql.sql' );
|
|||||||
|
|
||||||
$domain = shell_exec( 'wp option get siteurl' );
|
$domain = shell_exec( 'wp option get siteurl' );
|
||||||
$search_replace = trim( $domain ) . ' ' . trim( $staging_domain );
|
$search_replace = trim( $domain ) . ' ' . trim( $staging_domain );
|
||||||
|
|
||||||
|
// 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" );
|
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/post-smtp' );
|
||||||
rmdir( './wp-content/plugins/wordfence' );
|
rmdir( './wp-content/plugins/wordfence' );
|
||||||
|
|||||||
Reference in New Issue
Block a user