From ac3d3b5dd85899d556161b495a0d78d199718dfc Mon Sep 17 00:00:00 2001 From: mattyrob Date: Fri, 23 Jul 2021 10:47:30 +0100 Subject: [PATCH 1/2] Add Plugin and Theme check sections --- lib/admin-page.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/lib/admin-page.php b/lib/admin-page.php index 8680089..987ca43 100644 --- a/lib/admin-page.php +++ b/lib/admin-page.php @@ -449,6 +449,57 @@ function classicpress_check_can_migrate() { // TODO: Add instructions if WP too old. echo "\n"; + // Check: Conflicting Theme + $theme = wp_get_theme(); + if ( isset( $parameters['themes'] ) && in_array( $theme->stylesheet, (array) $parameters['themes'] ) ) { + $preflight_checks['theme'] = false; + echo "\n$icon_preflight_fail\n\n"; + printf( __( + /* translators: active theme name */ + 'It looks like you are using the %1$s theme. Unfortuantely it is incompatible with ClassicPress.', + 'switch-to-classicpress' + ), $theme->name ); + echo "
\n"; + _e( + 'Consider switching to a different theme, perhaps an older core theme, and try again.', + 'switch-to-classicpress' + ); + } else { + $preflight_checks['theme'] = true; + echo "\n$icon_preflight_pass\n\n"; + printf( __( + /* translators: active theme name */ + 'It looks like you are using the %1$s theme. We believe it is compatible with ClassicPress.', + 'switch-to-classicpress' + ), $theme->name ); + } + echo "\n"; + + // Check: Conflicting Plugins + $plugins = get_option( 'active_plugins' ); + if ( isset( $parameters['plugins'] ) && $plugins !== array_diff( $plugins, $parameters['plugins'] ) ) { + $preflight_checks['plugins'] = false; + + echo "\n$icon_preflight_fail\n\n"; + /* translators: URI to list of conflucting plugins */ + _e( + 'We have detected one or more incompatible plugins that prevent migrating your site to ClassicPress. ', + 'switch-to-classicpress' + ); + echo "
\n"; + printf( __( + 'Please visit our Forum for a list of known conflictong plugins.', + 'switch-to-classicpress' + ), 'https://docs.classicpress.net/installing-classicpress/#plugin-conflicts' ); + } else { + $preflight_checks['plugins'] = true; + echo "\n$icon_preflight_pass\n\n"; + _e( + 'We are not aware that any of your active plugins are incompatible with ClassicPress.', + 'switch-to-classicpress' + ); + } + // Check: Supported PHP version $php_version_min = '5.6'; if ( version_compare( PHP_VERSION, $php_version_min, 'lt' ) ) { @@ -600,6 +651,8 @@ function classicpress_check_can_migrate() { if ( $preflight_checks['wp_version'] && + $preflight_checks['theme'] && + $preflight_checks['plugins'] && $preflight_checks['php_version'] && $preflight_checks['wp_http_supports_ssl'] ) { From 2d122e137d6297bb2d45099f0c2a261051dffa6e Mon Sep 17 00:00:00 2001 From: mattyrob Date: Sat, 24 Jul 2021 16:34:58 +0100 Subject: [PATCH 2/2] Update based on comment feedback 'Pass' icons changes to 'Warn' icons as passing information rather than assuring a smooth migration. Fixed trailing white space. Added checks for parent / child theme pairings. Display names of conflicting plugins on-screen rather than linking to docs / forum for improved UX and easier maintenance. --- lib/admin-page.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/admin-page.php b/lib/admin-page.php index 987ca43..1801485 100644 --- a/lib/admin-page.php +++ b/lib/admin-page.php @@ -451,7 +451,10 @@ function classicpress_check_can_migrate() { // Check: Conflicting Theme $theme = wp_get_theme(); - if ( isset( $parameters['themes'] ) && in_array( $theme->stylesheet, (array) $parameters['themes'] ) ) { + if ( isset( $parameters['themes'] ) && + in_array( $theme->stylesheet, (array) $parameters['themes'] ) || + ( is_child_theme() && in_array( $theme->parent()->stylesheet, (array) $parameters['themes'] ) ) + ) { $preflight_checks['theme'] = false; echo "\n$icon_preflight_fail\n\n"; printf( __( @@ -466,10 +469,10 @@ function classicpress_check_can_migrate() { ); } else { $preflight_checks['theme'] = true; - echo "\n$icon_preflight_pass\n\n"; + echo "\n$icon_preflight_warn\n\n"; printf( __( /* translators: active theme name */ - 'It looks like you are using the %1$s theme. We believe it is compatible with ClassicPress.', + 'It looks like you are using the %1$s theme. We are not aware of any incompatibilities between this theme and ClassicPress.', 'switch-to-classicpress' ), $theme->name ); } @@ -480,20 +483,32 @@ function classicpress_check_can_migrate() { if ( isset( $parameters['plugins'] ) && $plugins !== array_diff( $plugins, $parameters['plugins'] ) ) { $preflight_checks['plugins'] = false; + $conflicting_plugins = array_intersect( $parameters['plugins'], $plugins ); + $conflicting_plugin_names = array(); + foreach( $conflicting_plugins as $conflicting_plugin ) { + $conflicting_plugin_data[] = get_plugin_data( WP_CONTENT_DIR . '/plugins/' . $conflicting_plugin ); + $conflicting_plugin_names[] = $conflicting_plugin_data[0]['Name']; + } + echo "\n$icon_preflight_fail\n\n"; - /* translators: URI to list of conflucting plugins */ _e( - 'We have detected one or more incompatible plugins that prevent migrating your site to ClassicPress. ', + 'We have detected one or more incompatible plugins that prevent migrating your site to ClassicPress.', 'switch-to-classicpress' ); echo "
\n"; + _e( + 'Please deactivate the following plugins if you wish to continue migrating your site to ClassicPress:', + 'switch-to-classicpress' + ); + echo "
\n"; + /* translators: List of conflicting plugin names */ printf( __( - 'Please visit our Forum for a list of known conflictong plugins.', + '%s', 'switch-to-classicpress' - ), 'https://docs.classicpress.net/installing-classicpress/#plugin-conflicts' ); + ), implode( ', ', $conflicting_plugin_names ) ); } else { $preflight_checks['plugins'] = true; - echo "\n$icon_preflight_pass\n\n"; + echo "\n$icon_preflight_warn\n\n"; _e( 'We are not aware that any of your active plugins are incompatible with ClassicPress.', 'switch-to-classicpress'