Browse Source

Enhance domain replacement process in wp-import.php with error handling and informative output

main
Roman Axelrod 4 months ago
parent
commit
4ebd020353
  1. 2
      .gitignore
  2. 14
      wp-import.php

2
.gitignore

@ -0,0 +1,2 @@
.idea
.vscode

14
wp-import.php

@ -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' );

Loading…
Cancel
Save