Add an admin notice about the upcoming change in PHP requirements (PHP 7.4 minimum) (#38604)

This commit is contained in:
Corey McKrill 2023-06-05 14:36:24 -07:00 committed by GitHub
commit 8840e9e5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Add an admin notice about the upcoming PHP version requirement change for PHP 7.3 users

View File

@ -57,6 +57,7 @@ class WC_Admin_Notices {
add_action( 'woocommerce_installed', array( __CLASS__, 'reset_admin_notices' ) );
add_action( 'wp_loaded', array( __CLASS__, 'add_redirect_download_method_notice' ) );
add_action( 'admin_init', array( __CLASS__, 'hide_notices' ), 20 );
self::add_action( 'admin_init', array( __CLASS__, 'maybe_remove_php74_required_notice' ) );
// @TODO: This prevents Action Scheduler async jobs from storing empty list of notices during WC installation.
// That could lead to OBW not starting and 'Run setup wizard' notice not appearing in WP admin, which we want
@ -119,8 +120,53 @@ class WC_Admin_Notices {
self::add_notice( 'template_files' );
self::add_min_version_notice();
self::add_maxmind_missing_license_key_notice();
self::maybe_add_php74_required_notice();
}
// phpcs:disable Generic.Commenting.Todo.TaskFound
/**
* Add an admin notice about the bump of the required PHP version in WooCommerce 8.2
* if the current PHP version is too old.
*
* TODO: Remove this method in WooCommerce 8.2.
*/
private static function maybe_add_php74_required_notice() {
if ( version_compare( phpversion(), '7.4', '>=' ) ) {
return;
}
self::add_custom_notice(
'php74_required_in_woo_82',
sprintf(
'%s%s',
sprintf(
'<h4>%s</h4>',
esc_html__( 'PHP version requirements will change soon', 'woocommerce' )
),
sprintf(
// translators: Placeholder is a URL.
wpautop( wp_kses_data( __( 'WooCommerce 8.2, scheduled for <b>October 2023</b>, will require PHP 7.4 or newer to work. Your server is currently running an older version of PHP, so this change will impact your store. Upgrading to at least PHP 8.0 is recommended. <b><a href="%s">Learn more about this change.</a></b>', 'woocommerce' ) ) ),
'https://developer.woocommerce.com/2023/06/05/new-requirement-for-woocommerce-8-2-php-7-4/'
)
)
);
}
/**
* Remove the admin notice about the bump of the required PHP version in WooCommerce 8.2
* if the current PHP version is good.
*
* TODO: Remove this method in WooCommerce 8.2.
*/
private static function maybe_remove_php74_required_notice() {
if ( version_compare( phpversion(), '7.4', '>=' ) && self::has_notice( 'php74_required_in_woo_82' ) ) {
self::remove_notice( 'php74_required_in_woo_82' );
}
}
// phpcs:enable Generic.Commenting.Todo.TaskFound
/**
* Show a notice.
*