Skip to content

Commit 62d8c5c

Browse files
xxsimoxxxxsimoxx
andauthored
Add override for WP version check in "General setting" (#118)
* Add override setting --------- Co-authored-by: xxsimoxx <simone@gieffeedizioni.it>
1 parent 25f6101 commit 62d8c5c

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

lib/admin-page.php

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ classicpress_show_migration_blocked_info();
210210

211211
?>
212212
<h2><?php esc_html_e( 'Feedback and Support', 'switch-to-classicpress' ); ?></h2>
213-
214213
<p class="cp-migration-info">
215214
<?php esc_html_e(
216215
"Do you have feedback about this plugin, or about ClassicPress itself? Need help with something? We'd love to know what you think!",
@@ -247,6 +246,46 @@ function_exists( 'classicpress_version' )
247246
<?php
248247
}
249248

249+
/**
250+
* Add an option under General Settings to ignore wp_version on migration.
251+
*
252+
* @since 1.6.0
253+
*/
254+
function classicpress_ignore_wp_version_settings_init() {
255+
if ( function_exists( 'classicpress_version' ) ) {
256+
return;
257+
}
258+
add_settings_field(
259+
'classicpress_ignore_wp_version',
260+
'Ignore WordPress version',
261+
'classicpress_ignore_wp_version_checkbox_callback',
262+
'general',
263+
'default'
264+
);
265+
register_setting( 'general', 'classicpress_ignore_wp_version' );
266+
}
267+
268+
/**
269+
* Render an option under General Settings to ignore wp_version on migration.
270+
*
271+
* @since 1.6.0
272+
*/
273+
function classicpress_ignore_wp_version_checkbox_callback() {
274+
$option = get_option( 'classicpress_ignore_wp_version' );
275+
echo '<input type="checkbox" id="classicpress_ignore_wp_version" name="classicpress_ignore_wp_version" value="1" ' . checked( 1, $option, false ) . '>';
276+
printf(
277+
esc_html__(
278+
/* translators: 1: markup for the link at the migration page, 2: closing markup */
279+
'Ignore WordPress version when migrating to ClassicPress using the %1$sClassicPress Migration Plugin%2$s.',
280+
'switch-to-classicpress'
281+
),
282+
'<a href="' . sanitize_url( admin_url( 'tools.php?page=switch-to-classicpress' ) ) . '">' , //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.WP.DeprecatedFunctions.sanitize_urlFound
283+
'</a>'
284+
);
285+
}
286+
287+
add_action( 'admin_init', 'classicpress_ignore_wp_version_settings_init' );
288+
250289
/**
251290
* Determine whether this WP install can be migrated to ClassicPress.
252291
*
@@ -428,7 +467,7 @@ function classicpress_check_can_migrate() {
428467
*
429468
* @param bool $ignore Ignore the WP version check. Defaults to false.
430469
*/
431-
if ( apply_filters( 'classicpress_ignore_wp_version', false ) ) {
470+
if ( apply_filters( 'classicpress_ignore_wp_version', false ) || get_option( 'classicpress_ignore_wp_version' ) === '1' ) {
432471
$preflight_checks['wp_version'] = true;
433472
echo "<tr>\n<td>" . wp_kses_post($icon_preflight_warn) . "</td>\n<td>\n";
434473
echo "<p>\n";
@@ -453,9 +492,15 @@ function classicpress_check_can_migrate() {
453492
echo wp_kses_post( "<tr>\n<td>$icon_preflight_fail</td>\n<td>\n" );
454493
echo "<p>\n";
455494
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>" );
495+
printf(
496+
esc_html__(
497+
/* translators: 1: markup for the link at the general settings page, 2: closing markup */
498+
'You can enable migration from this version of WordPress At Your Own Risk activating "Ignore WordPress version" in the %1$sGeneral options%2$s.',
499+
'switch-to-classicpress'
500+
),
501+
'<a href="' . sanitize_url( admin_url( 'options-general.php' ) ) . '">' , //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.WP.DeprecatedFunctions.sanitize_urlFound
502+
'</a>'
503+
);
459504
}
460505
} else {
461506
$preflight_checks['wp_version'] = true;

0 commit comments

Comments
 (0)