diff --git a/lib/admin-page.php b/lib/admin-page.php index d343277..93f5c54 100644 --- a/lib/admin-page.php +++ b/lib/admin-page.php @@ -449,6 +449,39 @@ function classicpress_check_can_migrate() { echo "\n

\n"; echo "\n"; + // Check: Conflicting files + $conflicting_files = classicpress_check_conflicting_files(); + if ( count( $conflicting_files ) > 0 ) { + $preflight_checks['conflicting_files'] = false; + echo "\n$icon_preflight_fail\n\n"; + } else { + $preflight_checks['conflicting_files'] = true; + echo "\n$icon_preflight_pass\n\n"; + } + echo "

\n"; + if ( $preflight_checks['conflicting_files'] ) { + _e( + 'No conflicting files were found.', + 'switch-to-classicpress' + ); + } else { + _e( + 'Conflicting files detected. These are files that would be unexpectedly overwritten during migration.', + 'switch-to-classicpress' + ); + echo "
\n"; + _e( + 'If you have JavaScript enabled, you can see a list of conflicting files in your browser console.', + 'switch-to-classicpress' + ); + echo "\n"; + } + echo "\n

\n"; + echo "\n"; + // Check: Core files checksums $modified_files = classicpress_check_core_files(); if ( $modified_files === false || ! empty( $modified_files ) ) { @@ -524,7 +557,8 @@ function classicpress_check_can_migrate() { if ( $preflight_checks['wp_version'] && $preflight_checks['php_version'] && - $preflight_checks['wp_http_supports_ssl'] + $preflight_checks['wp_http_supports_ssl'] && + $preflight_checks['conflicting_files'] ) { update_option( 'classicpress_preflight_checks', $preflight_checks, false ); return true; diff --git a/lib/check-core-files.php b/lib/check-core-files.php index 5f83559..fa1ba84 100644 --- a/lib/check-core-files.php +++ b/lib/check-core-files.php @@ -42,3 +42,24 @@ function classicpress_check_core_files( $locale = 'en_US' ) { } return $modified; } + +/** + * Check for known conflicting files. + * + * @since 0.6.0 + * + * @return array An array of conflicting filenames (empty if no conflits). + */ +function classicpress_check_conflicting_files() { + $files = array( + 'composer.json', + ); + + $conflict = array(); + foreach ( $files as $file ) { + if ( file_exists( ABSPATH . $file ) ) { + $conflict[] = $file; + } + } + return $conflict; +}