Skip to content

Commit

Permalink
Add Plugin and Theme check sections (#74)
Browse files Browse the repository at this point in the history
* Add Plugin and Theme check sections

* Update based on comment feedback
  • Loading branch information
mattyrob authored Aug 3, 2021
1 parent c48f5f6 commit 746a874
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions lib/admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,72 @@ function classicpress_check_can_migrate() {
// TODO: Add instructions if WP too old.
echo "</td></tr>\n";

// Check: Conflicting Theme
$theme = wp_get_theme();
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 "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n";
printf( __(
/* translators: active theme name */
'It looks like you are using the <strong>%1$s</strong> theme. Unfortuantely it is incompatible with ClassicPress.',
'switch-to-classicpress'
), $theme->name );
echo "<br>\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 "<tr>\n<td>$icon_preflight_warn</td>\n<td>\n";
printf( __(
/* translators: active theme name */
'It looks like you are using the <strong>%1$s</strong> theme. We are not aware of any incompatibilities between this theme and ClassicPress.',
'switch-to-classicpress'
), $theme->name );
}
echo "</td></tr>\n";

// Check: Conflicting Plugins
$plugins = get_option( 'active_plugins' );
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 "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n";
_e(
'We have detected one or more incompatible plugins that prevent migrating your site to ClassicPress.',
'switch-to-classicpress'
);
echo "<br>\n";
_e(
'Please deactivate the following plugins if you wish to continue migrating your site to ClassicPress:',
'switch-to-classicpress'
);
echo "<br>\n";
/* translators: List of conflicting plugin names */
printf( __(
'<strong>%s<sttong>',
'switch-to-classicpress'
), implode( ', ', $conflicting_plugin_names ) );
} else {
$preflight_checks['plugins'] = true;
echo "<tr>\n<td>$icon_preflight_warn</td>\n<td>\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' ) ) {
Expand Down Expand Up @@ -600,6 +666,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']
) {
Expand Down

0 comments on commit 746a874

Please sign in to comment.