Skip to content

Commit b664e9e

Browse files
committed
Add option to enable/disable automatic downgrades
1 parent 7fed399 commit b664e9e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

admin/settings.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$show_deprecations = jQuery_Migrate_Helper::show_deprecated_scripts_notice();
1212
$public_deprecations = get_option( '_jquery_migrate_public_deprecation_logging', 'no' );
1313
$log_modern_deprecations = get_option( '_jquery_migrate_modern_deprecations', 'no' );
14+
$has_auto_downgraded = get_option( '_jquery_migrate_has_auto_downgraded', 'no' );
1415
?>
1516

1617
<h2>Settings</h2>
@@ -51,6 +52,20 @@
5152
</td>
5253
</tr>
5354

55+
<?php if ( 'no' === $downgraded && is_wp_version_compatible( '5.6-alpha' ) ) : ?>
56+
<tr>
57+
<th scope="row">
58+
<?php _e( 'Automatic downgrades', 'enable-jquery-migrate-helper' ); ?>
59+
</th>
60+
<td>
61+
<label>
62+
<input name="automatic-downgrade" type="checkbox" <?php checked( ( 'no' === $has_auto_downgraded ) ); ?>>
63+
<?php _e( 'Allow website visitors to trigger an automatic downgrading to legacy jQuery, when a failure is detected', 'enable-jquery-migrate-helper' ); ?>
64+
</label>
65+
</td>
66+
</tr>
67+
<?php endif; ?>
68+
5469
<?php if ( 'no' === $downgraded && is_wp_version_compatible( '5.6-alpha' ) ) : ?>
5570
<tr>
5671
<th scope="row">

class-jquery-migrate-helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ public static function admin_settings() {
167167
} else {
168168
update_option( '_jquery_migrate_modern_deprecations', 'no' );
169169
}
170+
171+
if ( isset( $_POST['automatic-downgrade'] ) ) {
172+
update_option( '_jquery_migrate_has_auto_downgraded', 'no' );
173+
} else {
174+
update_option( '_jquery_migrate_has_auto_downgraded', 'yes' );
175+
}
170176
}
171177

172178
public static function site_health_check( $tests ) {

0 commit comments

Comments
 (0)