Skip to content

Commit 746a874

Browse files
authored
Add Plugin and Theme check sections (#74)
* Add Plugin and Theme check sections * Update based on comment feedback
1 parent c48f5f6 commit 746a874

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

lib/admin-page.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,72 @@ function classicpress_check_can_migrate() {
449449
// TODO: Add instructions if WP too old.
450450
echo "</td></tr>\n";
451451

452+
// Check: Conflicting Theme
453+
$theme = wp_get_theme();
454+
if ( isset( $parameters['themes'] ) &&
455+
in_array( $theme->stylesheet, (array) $parameters['themes'] ) ||
456+
( is_child_theme() && in_array( $theme->parent()->stylesheet, (array) $parameters['themes'] ) )
457+
) {
458+
$preflight_checks['theme'] = false;
459+
echo "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n";
460+
printf( __(
461+
/* translators: active theme name */
462+
'It looks like you are using the <strong>%1$s</strong> theme. Unfortuantely it is incompatible with ClassicPress.',
463+
'switch-to-classicpress'
464+
), $theme->name );
465+
echo "<br>\n";
466+
_e(
467+
'Consider switching to a different theme, perhaps an older core theme, and try again.',
468+
'switch-to-classicpress'
469+
);
470+
} else {
471+
$preflight_checks['theme'] = true;
472+
echo "<tr>\n<td>$icon_preflight_warn</td>\n<td>\n";
473+
printf( __(
474+
/* translators: active theme name */
475+
'It looks like you are using the <strong>%1$s</strong> theme. We are not aware of any incompatibilities between this theme and ClassicPress.',
476+
'switch-to-classicpress'
477+
), $theme->name );
478+
}
479+
echo "</td></tr>\n";
480+
481+
// Check: Conflicting Plugins
482+
$plugins = get_option( 'active_plugins' );
483+
if ( isset( $parameters['plugins'] ) && $plugins !== array_diff( $plugins, $parameters['plugins'] ) ) {
484+
$preflight_checks['plugins'] = false;
485+
486+
$conflicting_plugins = array_intersect( $parameters['plugins'], $plugins );
487+
$conflicting_plugin_names = array();
488+
foreach( $conflicting_plugins as $conflicting_plugin ) {
489+
$conflicting_plugin_data[] = get_plugin_data( WP_CONTENT_DIR . '/plugins/' . $conflicting_plugin );
490+
$conflicting_plugin_names[] = $conflicting_plugin_data[0]['Name'];
491+
}
492+
493+
echo "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n";
494+
_e(
495+
'We have detected one or more incompatible plugins that prevent migrating your site to ClassicPress.',
496+
'switch-to-classicpress'
497+
);
498+
echo "<br>\n";
499+
_e(
500+
'Please deactivate the following plugins if you wish to continue migrating your site to ClassicPress:',
501+
'switch-to-classicpress'
502+
);
503+
echo "<br>\n";
504+
/* translators: List of conflicting plugin names */
505+
printf( __(
506+
'<strong>%s<sttong>',
507+
'switch-to-classicpress'
508+
), implode( ', ', $conflicting_plugin_names ) );
509+
} else {
510+
$preflight_checks['plugins'] = true;
511+
echo "<tr>\n<td>$icon_preflight_warn</td>\n<td>\n";
512+
_e(
513+
'We are not aware that any of your active plugins are incompatible with ClassicPress.',
514+
'switch-to-classicpress'
515+
);
516+
}
517+
452518
// Check: Supported PHP version
453519
$php_version_min = '5.6';
454520
if ( version_compare( PHP_VERSION, $php_version_min, 'lt' ) ) {
@@ -600,6 +666,8 @@ function classicpress_check_can_migrate() {
600666

601667
if (
602668
$preflight_checks['wp_version'] &&
669+
$preflight_checks['theme'] &&
670+
$preflight_checks['plugins'] &&
603671
$preflight_checks['php_version'] &&
604672
$preflight_checks['wp_http_supports_ssl']
605673
) {

0 commit comments

Comments
 (0)