Skip to content

Commit 93b0faf

Browse files
EliteStarServicesxxsimoxx
andauthored
Update to Plugin and Theme Warnings (#116)
* Updated Checks and Warnings: Warn if any plugins active Warn if theme not 2017 Show Modified Files On branch master Changes to be committed: modified: lib/admin-page.php * Improve checks and warnings Changes to be committed: modified: lib/admin-page.php * Comment out plugins found Changes to be committed: modified: lib/admin-page.php * - Change Plugin and Theme Checks to explain safest method, but only warn if not followed - Change Core File check to show any modified files on the page rather than in the console - Correct links and update verbiage as needed - bump to v1.5.3 Changes to be committed: modified: README.md modified: lib/admin-page.php modified: switch-to-classicpress.php * - Display override function info for unsupported WP versions when applicable Changes to be committed: modified: README.md modified: lib/admin-page.php * Changes proposed on Zulip * Fix Since * - Remove code no longer needed Changes to be committed: modified: lib/admin-page.php --------- Co-authored-by: xxsimoxx <simone@gieffeedizioni.it>
1 parent 5ca0ff6 commit 93b0faf

File tree

3 files changed

+51
-155
lines changed

3 files changed

+51
-155
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ supports migrating multisite WordPress installations to ClassicPress.
211211
- Adjust checks, notifications and information text as needed for CP v2
212212
- Warn that Migration requires Re-Install (reminder if you go back into the plugin)
213213
- Chat link changed from Slack to Zulip
214-
- Offer CP v1 & v2 current and one version back (unless no previous as with 2 right now)
215-
- Offer WP current, 6.3.x and 4.9.x (4.9 offered only if running PHP 7)
214+
- Offer CP v1 & v2 current and one version back (unless no previous)
215+
- Offer WP current, 6.2.x and 4.9.x (4.9 offered only if running PHP 7)
216216
- Offer release version if running CP migration version
217217
- Will not offer re-installation
218218
- Suggest a ClassicPress Default theme
@@ -225,3 +225,10 @@ supports migrating multisite WordPress installations to ClassicPress.
225225
### 1.5.2
226226

227227
- Update Code to CPCS
228+
229+
### 1.5.3
230+
231+
- Change Plugin and Theme Checks to explain safest method, but only warn if not followed
232+
- Change Core File check to show any modified files on the page rather than in the console
233+
- Display override function info for unsupported WP versions when applicable
234+
- Correct links and update wording as needed

lib/admin-page.php

Lines changed: 39 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ classicpress_show_migration_blocked_info();
224224
'For support, suggestions for improvement, or general discussion about how the plugin works, visit us in our <a href="%1$s">support forum</a> or <a href="%2$s">Zulip chat</a>.',
225225
'switch-to-classicpress'
226226
),
227-
'https://forums.classicpress.net/c/support/migration-plugin',
227+
'https://forums.classicpress.net/tags/c/plugins/9/migration-plugin',
228228
'https://classicpress.zulipchat.com/register/'
229229
); ?></li>
230230
<li><?php printf(
@@ -404,9 +404,9 @@ function classicpress_check_can_migrate() {
404404
$wp_version_max = $cp_api_parameters['wordpress']['max'];
405405
/* translators: 1: minimum supported WordPress version, 2: maximum supported WordPress version */
406406
$wp_version_check_intro_message = sprintf( __(
407-
'This plugin supports WordPress versions <strong>%1$s</strong> to <strong>%2$s</strong> (and some newer development versions).',
407+
'This plugin supports WordPress versions <strong>%1$s</strong> to <strong>%2$s</strong> (and some newer development versions).<br>You are running WordPress version <strong>%3$s</strong>.',
408408
'switch-to-classicpress'
409-
), $wp_version_min, $wp_version_max );
409+
), $wp_version_min, $wp_version_max, $wp_version );
410410
$wp_version_check_intro_message .= "<br>\n";
411411

412412
if (
@@ -434,17 +434,17 @@ function classicpress_check_can_migrate() {
434434
echo "<p>\n";
435435
echo wp_kses_post( $wp_version_check_intro_message );
436436
echo wp_kses_post(
437-
'The preflight check for supported WordPress versions has been <strong class="cp-emphasis">disabled</strong>.',
437+
'The check for supported WordPress versions has been <strong class="cp-emphasis">Manually Disabled</strong>.',
438438
'switch-to-classicpress'
439439
);
440440
echo "<br>\n";
441441
esc_html_e(
442-
'We cannot guarantee that the migration process is going to work, and it may even leave your current installation partially broken.',
442+
'We cannot guarantee that the migration process is going to work, and it may leave your current installation broken.',
443443
'switch-to-classicpress'
444444
);
445445
echo "<br>\n";
446446
echo wp_kses_post(
447-
'<strong class="cp-emphasis">Proceed at your own risk!</strong>',
447+
'<strong class="cp-emphasis">Proceed At Your Own Risk!</strong>',
448448
'switch-to-classicpress'
449449
);
450450
echo "<br>\n";
@@ -453,6 +453,9 @@ function classicpress_check_can_migrate() {
453453
echo wp_kses_post( "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n" );
454454
echo "<p>\n";
455455
echo wp_kses_post( $wp_version_check_intro_message );
456+
echo wp_kses_post( "You can enable migration from this version of WordPress <strong class='cp-emphasis'>At Your
457+
Own Risk</strong><br>Use the following code in your current theme's
458+
`functions.php` file or a mu-plugin to allow migration:<br><code>add_filter( 'classicpress_ignore_wp_version', '__return_true' );</code>" );
456459
}
457460
} else {
458461
$preflight_checks['wp_version'] = true;
@@ -464,68 +467,28 @@ function classicpress_check_can_migrate() {
464467
echo "<p>\n";
465468
echo wp_kses_post( $wp_version_check_intro_message );
466469
}
467-
/* translators: current WordPress version */
468-
printf( wp_kses_post(
469-
'You are running WordPress version <strong>%s</strong>.',
470-
'switch-to-classicpress'
471-
), esc_html( $wp_version ) );
470+
472471
if ( substr( $wp_version, 0, 1 ) >= '5' && $preflight_checks['wp_version'] ) {
473-
echo "<br>\n";
474-
esc_html_e(
475-
'Migration is supported, but content edited with the WordPress Block Editor may not be fully compatible with ClassicPress.',
476-
'switch-to-classicpress'
477-
);
478-
/* THIS NEXT LINE IS DISABLED - I THINK THE ABOVE IS ENOUGH
479-
echo "<br>\n";
472+
//echo "<br>\n";
480473
esc_html_e(
481-
'After the migration, we recommend reviewing each recently edited post or page and restoring to an earlier revision if needed.',
474+
'Content edited with the WordPress Block Editor may not be fully compatible with ClassicPress.',
482475
'switch-to-classicpress'
483476
);
484-
*/
477+
485478
}
486479
echo "\n</p>\n";
487480
// TODO: Add instructions if WP too old.
488481
echo "</td></tr>\n";
489482

490-
// Check: Conflicting Theme
483+
// Theme Check
491484
$theme = wp_get_theme();
492485
$theme_name = $cp_api_parameters['defaults']['theme_name'];
493486
$theme_url = $cp_api_parameters['defaults']['theme_url'];
494487
$default_theme = "<a href='$theme_url'>$theme_name</a>";
495-
$theme_info = "<li>The safest way of switching to ClassicPress is by (temporarily) installing and activating the fully compatible theme <strong>$default_theme</strong>.</li>";
496-
$fse_info = "<br>Block and Full Screen Editor themes may work in ClassicPress, but you will have to test the theme(s) you plan to use and verify that they work correctly.";
497-
if (
498-
in_array( $theme->stylesheet, (array) $cp_api_parameters['themes'] ) ||
499-
( is_child_theme() && in_array( $theme->parent()->stylesheet, (array) $cp_api_parameters['themes'] ) )
500-
) {
501-
$preflight_checks['theme'] = false;
502-
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_fail) . "</td>\n<td>\n<p>\n";
503-
/* translators: active theme name */
504-
printf( wp_kses_post(
505-
'It looks like you are using the <strong>%1$s</strong> theme. Unfortunately, %1$s is known to be incompatible with ClassicPress.%2$s',
506-
'switch-to-classicpress'
507-
), esc_html( $theme->name ), wp_kses_post( $fse_info ) );
508-
echo "<br>\n";
509-
echo wp_kses_post(
510-
$theme_info,
511-
'switch-to-classicpress'
512-
);
513-
// } elseif ( version_compare( $theme->get( 'RequiresWP' ), '5.0' ) >= 0 ) {
514-
} elseif ( in_array( 'full-site-editing', $theme->tags ) ) {
515-
$preflight_checks['theme'] = false;
516-
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_fail) . "</td>\n<td>\n<p>\n";
517-
printf( wp_kses_post(
518-
/* translators: active theme name */
519-
'It looks like you are using the <strong>%1$s</strong> theme. Unfortunately, %1$s is probably using FSE functions and may not be compatible with ClassicPress.%2$s',
520-
'switch-to-classicpress'
521-
// ), $theme->name, $theme->get( 'RequiresWP' ) );
522-
), esc_html( $theme->name ), wp_kses_post( $fse_info ) );
523-
echo "<br>\n";
524-
echo wp_kses_post(
525-
$theme_info,
526-
'switch-to-classicpress'
527-
);
528-
} elseif ( $theme->name === $theme_name ) {
488+
$theme_info = "<strong>The safest way of switching to ClassicPress is to install and activate the fully compatible theme <em>$default_theme</em>.</strong>
489+
<br>You can <strong class='cp-emphasis'>Continue at Your Own Risk</strong> with your current theme, but you may experience issues if the theme is not compatible with ClassicPress.";
490+
// THEME CHECKS DISABLED / WARN ONLY (Since v1.6)
491+
if ( $theme->name === $theme_name ) {
529492
$preflight_checks['theme'] = true;
530493
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_pass) . "</td>\n<td>\n<p>\n";
531494
printf( wp_kses_post(
@@ -536,8 +499,8 @@ function classicpress_check_can_migrate() {
536499
$preflight_checks['theme'] = true;
537500
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_warn) . "</td>\n<td>\n<p>\n";
538501
printf( wp_kses_post(
539-
/* translators: active theme name */
540-
'It looks like you are using the <strong>%1$s</strong> theme. We are not aware of any incompatibilities between %1$s and ClassicPress.',
502+
// translators: active theme name
503+
'It looks like you are using the theme <strong>%1$s</strong>, you should test the theme(s) you plan to use after migration and verify that they work correctly.',
541504
'switch-to-classicpress'
542505
), esc_html( $theme->name ) );
543506
echo "<br>\n";
@@ -548,104 +511,32 @@ function classicpress_check_can_migrate() {
548511
}
549512
echo "</p></td></tr>\n";
550513

551-
// Check: Conflicting Plugins
514+
// Plugins Check
552515
$plugins = get_option( 'active_plugins' );
553516
$plugin_headers = array( 'Name' => 'Plugin Name', 'RequiresWP' => 'Requires at least' );
554517
$declared_incompatible_plugins = array();
555518
$undeclared_compatibility_plugins = array();
556-
$plugin_info = "<br>Plugins that require Blocks might not work in ClassicPress, you should test the plugins you plan to use and verify they work correctly.";
557-
558-
// Start by checking if plugins have declared they require WordPress 5.0 or higher
559-
foreach ( $plugins as $plugin ) {
560-
if ( in_array( $plugin, $cp_api_parameters['plugins'] ) ) {
561-
continue;
562-
}
563-
$plugin_data = get_file_data( WP_PLUGIN_DIR . '/' . $plugin, $plugin_headers );
564-
$plugin_name = $plugin_data['Name'];
565-
if ( version_compare( $plugin_data['RequiresWP'], '5.0' ) >= 0 ) {
566-
$undeclared_compatibility_plugins[ $plugin ] = $plugin_name;
567-
} else {
568-
$plugin_files = get_plugin_files( $plugin );
569-
$readmes = array_filter( $plugin_files, function ( $files ) {
570-
return ( stripos( $files, 'readme') !== false );
571-
} );
572-
foreach( $readmes as $readme ) {
573-
if ( empty( $readme ) ) {
574-
continue;
575-
}
576-
$readme_data = get_file_data( WP_PLUGIN_DIR . '/' . $readme, $plugin_headers );
577-
if ( version_compare( $readme_data['RequiresWP'], '5.0' ) >= 0 ) {
578-
$undeclared_compatibility_plugins[ $plugin ] = $plugin_name;
579-
continue;
580-
}
581-
}
582-
}
583-
if (
584-
empty( $plugin_data['RequiresWP'] ) &&
585-
( empty( $readmes ) || empty( $readme_data['RequiresWP'] ) ) &&
586-
false === array_key_exists( $plugin, $declared_incompatible_plugins )
587-
) {
588-
$undeclared_compatibility_plugins[ $plugin ] = $plugin_name;
589-
}
590-
}
519+
$plugin_info = "It looks like you have active plugins, you should test the plugins you plan to use after migration and verify they work correctly.";
591520

592-
// Compare active plugins with API response of known conflicting plugins
593-
if (
594-
$plugins !== array_diff( $plugins, $cp_api_parameters['plugins'] ) ||
595-
! empty( $declared_incompatible_plugins )
596-
) {
597-
$preflight_checks['plugins'] = false;
598-
$conflicting_plugins = array_intersect( $cp_api_parameters['plugins'], $plugins );
599-
$conflicting_plugin_names = array();
600-
foreach( $conflicting_plugins as $conflicting_plugin ) {
601-
$conflicting_plugin_data = get_plugin_data( WP_CONTENT_DIR . '/plugins/' . $conflicting_plugin );
602-
$conflicting_plugin_names[] = $conflicting_plugin_data['Name'];
603-
}
604-
if ( ! empty( $declared_incompatible_plugins ) ) {
605-
foreach( $declared_incompatible_plugins as $slug => $name ) {
606-
$conflicting_plugin_names[] = $name;
607-
}
608-
}
609-
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_fail) . "</td>\n<td>\n<p>\n";
610-
esc_html_e(
611-
'We have detected one or more known incompatible plugins that prevent migrating your site to ClassicPress.',
612-
'switch-to-classicpress'
613-
);
614-
echo "<br>\n";
615-
esc_html_e(
616-
'Please deactivate the following plugins if you wish to continue migrating your site to ClassicPress:',
617-
'switch-to-classicpress'
618-
);
619-
echo "<br>\n";
620-
/* translators: List of conflicting plugin names */
621-
printf( wp_kses_post(
622-
'<strong>%s<strong>',
623-
'switch-to-classicpress'
624-
), esc_html( implode( ', ', $conflicting_plugin_names ) ) );
625-
} elseif ( ! empty( $undeclared_compatibility_plugins ) ) {
521+
if ( count($plugins) > 1 ) {
626522
$preflight_checks['plugins'] = true;
627523
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_warn) . "</td>\n<td>\n<p>\n";
628524
echo wp_kses_post(
629-
'We have detected one or more plugins that may require Blocks or fail to declare a compatible WordPress version.'.$plugin_info,
525+
$plugin_info,
630526
'switch-to-classicpress'
631527
);
632528
echo "<br>\n";
633529
echo wp_kses_post(
634-
'<li>The safest way of switching to ClassicPress is to (temporarily) deactivate the following plugin(s):</li>',
530+
"<strong>The safest way of switching to ClassicPress is to (temporarily) deactivate your plugins, except <em>Switch to ClassicPress</em>.</strong>
531+
<br>You can <strong class='cp-emphasis'>Continue at Your Own Risk</strong> with active plugins, but you may experience issues if any plugins are not compatible with ClassicPress.",
635532
'switch-to-classicpress'
636533
);
637-
//echo "<br>\n";
638-
/* translators: List of conflicting plugin names */
639-
printf( wp_kses_post(
640-
'<strong>%s<strong>',
641-
'switch-to-classicpress'
642-
), esc_html( implode( ', ', $undeclared_compatibility_plugins ) ) );
643534
echo "</p></td></tr>\n";
644535
} else {
645536
$preflight_checks['plugins'] = true;
646-
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_warn) . "</td>\n<td>\n<p>\n";
537+
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_pass) . "</td>\n<td>\n<p>\n";
647538
esc_html_e(
648-
'We are not aware that any of your active plugins are incompatible with ClassicPress.',
539+
'It looks like you have no plugins or have deactived plugins other than Switch to ClassicPress, this is the safest way to migrate your site to ClassicPress.',
649540
'switch-to-classicpress'
650541
);
651542
}
@@ -741,7 +632,7 @@ function classicpress_check_can_migrate() {
741632
}
742633
echo "<p>\n";
743634
esc_html_e(
744-
'Your WordPress core files will be overwritten.',
635+
'WordPress core files will be overwritten during the migration.',
745636
'switch-to-classicpress'
746637
);
747638
echo "\n<br>\n";
@@ -763,17 +654,15 @@ function classicpress_check_can_migrate() {
763654
} else {
764655
echo '<strong class="cp-emphasis">';
765656
esc_html_e(
766-
'Modified core files detected. These customizations will be lost.',
657+
'Modified core files detected. These customizations will be lost:',
767658
'switch-to-classicpress'
768659
);
769660
echo "</strong>\n<br>\n";
770-
echo wp_kses_post(
771-
'If you have JavaScript enabled, you can see a list of modified files <strong>in your browser console</strong>.',
772-
'switch-to-classicpress'
773-
);
774-
echo "\n<script>console.log( 'modified core files:', ";
775-
echo wp_json_encode( $modified_files );
776-
echo ' );</script>';
661+
foreach ( $modified_files as $file ) {
662+
// translators: modified core file name
663+
echo esc_html( sprintf( ' - %s', $file ) ) . "<br>\n";
664+
}
665+
777666
}
778667
echo "\n</p>\n";
779668
echo "</td></tr>\n";
@@ -823,7 +712,7 @@ function classicpress_check_can_migrate() {
823712
* Show the controls and information needed to migrate to ClassicPress.
824713
*
825714
* NOTE: ONLY CALL THIS FUNCTION IF ALL PRE-FLIGHT CHECKS HAVE PASSED!
826-
* Otherwise you *will* end up with a broken site!
715+
* Otherwise you could end up with a broken site!
827716
*
828717
* @since 0.1.0
829718
*/
@@ -910,7 +799,7 @@ function classicpress_show_migration_blocked_info() {
910799
'If you\'re not sure how to fix the issues above, you can ask for help in our <a href="%s">Support Forum</a>.',
911800
'switch-to-classicpress'
912801
),
913-
'https://forums.classicpress.net/c/support/migration-plugin'
802+
'https://forums.classicpress.net/tags/c/plugins/9/migration-plugin'
914803
);
915804
?>
916805
</p>
@@ -1036,13 +925,13 @@ class="hidden"
1036925
<td>
1037926
<p>
1038927
<?php echo wp_kses_post(
1039-
'If all requirements for your custom version have been met, then migration should complete.</p><p>That does not mean it will be successful in every case and<strong class="cp-emphasis"> Older Versions May Not be Secure!</strong></p>',
928+
'If all requirements for your custom version have been met, then migration should complete.</p><p>That does not mean it will work in every case and<strong class="cp-emphasis"> Older Versions may have Password or Security Issues!</strong></p>',
1040929
'switch-to-classicpress'
1041930
); ?>
1042931
</p>
1043932
<p>
1044933
<?php echo wp_kses_post(
1045-
'Please, make a <strong class="cp-emphasis">Complete Backup of your Site</strong> before using this tool<strong class="cp-emphasis"> At Your Own Risk!</strong>',
934+
'Please, make a <strong class="cp-emphasis">Complete Backup of your Site Files and Database</strong> before using this tool<strong class="cp-emphasis"> At Your Own Risk!</strong>',
1046935
'switch-to-classicpress'
1047936
); ?>
1048937
</p>

switch-to-classicpress.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Plugin Name: Switch to ClassicPress
44
* Plugin URI: https://github.com/ClassicPress/ClassicPress-Migration-Plugin
55
* Description: Switch your WordPress installation to ClassicPress.
6-
* Version: 1.5.2
7-
* Author: ClassicPress
6+
* Version: 1.6.0
7+
* Author: ClassicPress Team
88
* Author URI: https://www.classicpress.net
99
* License: GPLv2 or later
1010
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
@@ -13,7 +13,7 @@
1313
* Requires CP: 1.7
1414
* Requires PHP: 7.4
1515
* Requires at least: 4.9
16-
* Tested up to: 6.7
16+
* Tested up to: 6.8
1717
* Network: true
1818
* @package ClassicPress
1919
*/

0 commit comments

Comments
 (0)